jQuery in Action, 3rd edition
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 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: 1067




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: 42958
    
  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: 11882
    
  18

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

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
 
It's not a secret anymore!