enthuware.ocajp.i.v7.2.1027
Posted: Mon Aug 12, 2013 6:42 am
Hi,
I don't understand this explanation.
1. Where has x been assigned a new Integer object with the value of 6?
2. Why does x have the value of 5 when it's printed and the explanation tells me it's containing 6?
Wrapper objects are always immutable. Therefore, when dataWrapper is passed into wiggler() method, it is never changed even when x++; is executed. However, x, which was pointing to the same object as dataWrapper, is assigned a new Integer object (different from dataWrapper) containing 6.
Any help would be very much appreciated
I don't understand this explanation.
1. Where has x been assigned a new Integer object with the value of 6?
2. Why does x have the value of 5 when it's printed and the explanation tells me it's containing 6?
Wrapper objects are always immutable. Therefore, when dataWrapper is passed into wiggler() method, it is never changed even when x++; is executed. However, x, which was pointing to the same object as dataWrapper, is assigned a new Integer object (different from dataWrapper) containing 6.
Any help would be very much appreciated