File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Why is autoboxing not happening Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Why is autoboxing not happening" Watch "Why is autoboxing not happening" New topic
Author

Why is autoboxing not happening

Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1057




Why is autoboxing not happening why is it giving error at go(z);


http://www.lifesbizzare.blogspot.com || OCJP:81%
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42954
    
  73
Boxing an int results in an Integer, not a Long. Those two are not assignment-compatible.

If you want a method that can be used for both, declare it as taking a Number - that covers both Long and Integer.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11650
    
  17

Vishal,

I see that Ulf has already answered your question, but can I give you a tip on how to make better posts? When you say "why is it giving error at XXX", it can be of tremendous help to your fellow ranchers if you post the actual error you get. It makes it much easier for someone to look and focus in on the problem, making it more likely they will help you.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1057

Sure Fred, will not repeat the same mistake
 
Consider Paul's rocket mass heater.
 
subject: Why is autoboxing not happening