You cannot compile that code with JDK 1.4. Because it will try to use an overloaded operator that sums two Integers, and that operator does not exists, nor the operator that sums a primitive interger with an Integer.
That's why. May you're compiling the code with JDK 1.5 and autoboxing is happening automatically.
Joined: Apr 29, 2002
Yeah youre right, im using jdk 1.5. Thanks! I didnt know that.
This is a very subtle change between the versions and it will affect many existing questions. I have spent a huge amount of time over the last few months working on JDK 1.5 mock exams and this includes compiling up code like this to see if effects like autoboxing change the result. In several cases the answer to the question changes.
(note these new questions are not available for consumption yet) [ April 27, 2005: Message edited by: Marcus Green ]