| Author |
Wrappers
|
James Tharakan
Ranch Hand
Joined: Aug 29, 2008
Posts: 580
|
|
Both t and I are reference variables, holding the memory location of their respective objects.
Using final(for the test object) ,implies that the contents of the reference cannot be changed BUT the object state can be changed.
Isn't it the same for Integer reference. If not why??
|
SCJP 6
Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !
|
 |
Wouter Oet
Saloon Keeper
Joined: Oct 25, 2008
Posts: 2700
|
|
Because the increment operation tries to unbox the Integer, increment it, create a new Integer with that value and assign it to I.
Edit: wrapper classes are immutable
|
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
|
 |
kshitij dogra
Ranch Hand
Joined: Dec 28, 2008
Posts: 39
|
|
|
What is actually happening is that the Integer i , is being unboxed and then incremented , and then again boxed back to the value.......
|
SCJP 5.0 - 100%
|
 |
James Tharakan
Ranch Hand
Joined: Aug 29, 2008
Posts: 580
|
|
|
got it..
|
 |
 |
|
|
subject: Wrappers
|
|
|