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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 1050




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: 39576
    
  27
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.


Ping & DNS - updated with new look and Ping home screen widget
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10925
    
  12

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: 1050

Sure Fred, will not repeat the same mistake
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why is autoboxing not happening
 
Similar Threads
varargs doubt
Why doest it print it?
casting
Value of hexadecimal 0xDeadCafe