the old object remains and a new object is created
The
string literal pool is not part of the immutable behaviour of a class. (Have a read of
this). Immutable just means you can't change the value of something, it doesn't imply that such an object will be stored differently.
The string literal pool is part of the JVM. You can't get objects of other types to use it. But you can (sort of) implement simmilar logic if you control access to the construction of a new instance of your object. Have a google for "factory patterns" and you'll get a lot of information on the subject.
[ June 16, 2008: Message edited by: Paul Sturrock ]