This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
Integer class's object is immutable...
Posted by Kishori Sharan on March 14, 2001 at 9:56 AM
All wrapper classes in Java are immutable i.e. once created cannot be assigned a new value. When you want to set a new value to myInt you need to write myInt = new Integer ( 20 ) ; That is, you need to create a new object of Integer class and then assign the reference to myInt.
Replies:
|