posted 14 years ago
Once the objects are added to the Set... It will be referred by the references in the Set... Here, you added Integer object having "46" to the set... That will be referred by reference in the Set...
In line1, i2 starts to refer to the Integer object "47". It does not mean that Integer object containing 46 will be changed to 47...
In line2, Integer object "47" is given to be removed... Search is made in the Set and removal does not occur since no Integer Object 47 is available...
So, the output is 46 and the size is retained as 1...
SCJP 6 [SCJP - Old is Gold]