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

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: 35
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
I agree. Here's the link:
subject: Doubt in Integer and int
It's not a secret anymore!