Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt in Integer and int  RSS feed

 
asha ganapathy
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/* 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
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Kaydell
 
Abhishek Kanchan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!