| Author |
Confusion about string objects
|
Roger Fed
Ranch Hand
Joined: Oct 17, 2010
Posts: 82
|
|
|
Can anyone explain the meaning that string objects is immutable?
|
I Hear I Forget, I See I Remember, I Do I Understand.
|
 |
Hussein Baghdadi
clojure forum advocate
Bartender
Joined: Nov 08, 2003
Posts: 3359
|
|
Basically it means that once you created a String, you can't change it (one of its characters for example).
Any operation like swapping a character, upper casing it and others is going to create a new String.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Note that you can't change the String object, but changing the String reference is possible (if the variable isn't final):
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Sunny Bhandari
Ranch Hand
Joined: Dec 06, 2010
Posts: 446
|
|
Hi Roger, you can see the source code of String API methods to research more on this topic....
It will give you more knowledge and confidence on this popular question...
|
 |
 |
|
|
subject: Confusion about string objects
|
|
|