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
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply 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: 969




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


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

Joined: Mar 22, 2005
Posts: 35223
    
    7
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.


Android appsImageJ pluginsJava web charts
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9939
    
    6

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.


Never ascribe to malice that which can be adequately explained by stupidity.
Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 969

Sure Fred, will not repeat the same mistake
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Why is autoboxing not happening
 
Similar Threads
casting
varargs doubt
Value of hexadecimal 0xDeadCafe
Why doest it print it?