First, look at line 1...
Integer.parseInt("1") returns an int based on the
String argument. Passing this int to the Integer constructor creates a new Integer. Then calling intValue() on this Integer instance returns an int. This int is what's assigned to int i1.
Now, reconsider line 2...
This is exactly the same as line 1
except that it trys to assign the int to an Integer instance, i3, resulting in a compile-time error.
On to line 3...
Integer.valueOf("1") returns an instance of Integer based on the String argument. Then calling toString returns it back to a String. This String is then used as an argument in Integer.parseInt, which returns an int. It's this int that's assigned to int i2.
And line 4...
As on line 3, Integer.valueOf("1") returns an instance of Integer based on the String argument. But here, calling intValue on this Integer instance returns an int, which is passed to Integer.parseInt. Unfortunately, parseInt does not take an int argument, so we get a compile-time error.
[ October 20, 2004: Message edited by: marc weber ]