This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in Integer and int Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in Integer and int" Watch "Doubt in Integer and int" New topic

Doubt in Integer and int

asha ganapathy
Ranch Hand

Joined: Nov 03, 2006
Posts: 54
/* Code 1 */

In the above example i understood that here the compiler is confused to choose between both the overloaded methods, hence there is compiler error
/* Code 2 */

But in this example there are no compilation errors like the previous one.
i would like to know why?
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 688

I think that the way to understand the way that things are in Java 5.0 is to understand that in previous versions of Java there was no auto-boxing. So, for backward compatibility with Java version 1.4 (also known as 4.0) things in 5.0 have to be done the old way -- the way that they used to be done in 1.4 and earlier. This is necessary so that existing code works when upgrading to 5.0.

Abhishek Kanchan
Ranch Hand

Joined: May 10, 2007
Posts: 32
I think there is an error in first method call where you are passing a reference to an int array where an Integer or int is expected.
To clear your doubts on autoboxing go through Zaikin's Tiger notes.

SCJP 1.5<br />SCWCD 5.0
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Doubt in Integer and int
Similar Threads
Method resolution
Ambiguity in calling Varargs
re: ambiguous method calls