SEED
a seed of dream
JDK Code Reading - String
Introduction
String class is used to represents character strings in Java. The strings of this class are immutable once they are created.
Immutablness
Programcreek gives 5 reasons for immutablesness of String in Java.
- A immuatble object in object pool can be reused to avoid overhead of creating a new object.
- The hashcode of a String object can be cached to avoid the overhead caused by computing hashcode.
- Facilitating the use of other objects
- Security, prevent other’s modification
- Thread-safe
Internally, String class store the data in a char array.
private final char value[];