Java Reference
In-Depth Information
Here is the output from this program:
Strings Are Immutable
The contents of a String object are immutable. That is, once created, the character se-
quence that makes up the string cannot be altered. This restriction allows Java to implement
strings more efficiently. Even though this probably sounds like a serious drawback, it isn't.
When you need a string that is a variation on one that already exists, simply create a
new string that contains the desired changes. Since unused String objects are automatic-
ally garbage collected, you don't even need to worry about what happens to the discarded
Search WWH ::




Custom Search