General info about Java Strings could be found in
API Doc.
Strings are
immutable. So they can't be changed.
Strings store
value internally in
char array and have
offset of the first character and characters
count.
private final char value[];
private final int offset;
private final int count;
Example of initialization of empty String:
public String() {
this.offset = 0;
this.count = 0;
this.value = new char[0];
}Strings could share the same
character array. Check
constructor and
substring code:
String(int offset, int count, char value[]) {
this.value = value;
this.offset = offset;
this.count = count;
}
public String substring(int beginIndex, int endIndex) {
...
return ((beginIndex == 0) && (endIndex == count)) ? this :
new String(offset + beginIndex, endIndex - beginIndex, value);
}
Sample:
String str = "Hello World";
String substr = str.substring(6, 11);

Low level system implementation of
String class follows
Flyweight Design Pattern
public native String intern();
Sample:
String world = "World";
String str = "Hello World";
String substr1 = str.substring(6, 11);
String substr2 = str.substring(6, 11).intern();