Page 1 of 1

About Question com.enthuware.ets.scjp.v6.2.32

Posted: Sun Aug 10, 2014 1:09 am
by sarmadys
Hello,

- Clicking on discussion of this question will bring you to question 235 instead.
- I still do not understand the answer. I don't see where the new integer is assigned (and where the value 6 was given to it).
However, x, which was pointing to the same object as dataWrapper, is assigned a new Integer object (different from dataWrapper) containing 6.
Regards

P.S. I am adding a snapshot (in case the q# is wrong). Please remove it if it is not fine.

Re: About Question com.enthuware.ets.scjp.v6.2.32

Posted: Sun Aug 10, 2014 4:40 am
by admin
It is assigned at x++.

Re: About Question com.enthuware.ets.scjp.v6.2.32

Posted: Sun Aug 10, 2014 5:55 am
by sarmadys
aah, the initial x is immutable but since the command is equal to

x = x + 1;

in fact a new immutable Integer object is created (with a value of 6) and assigned to the reference x.

Thank you.