wood burning stoves 2.0*
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 Spring in Action this week in the Spring 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: 1055




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: 42276
    
  64
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 - my free Android networking tools app
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11407
    
  16

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

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