«^»
3.5. Copying String objects

As was shown with the class java.awt.Point, you can make another variable refer to the same string by an assignment statement:

String tName = new String("James Gosling");
String tSameName = tName;
Both reference variables refer to the same object.

Earlier, when we used the String constructor, we passed a string literal as an argument. If you want a clone of a String object, then you can pass that String object as the argument of a String constructor:

String tName = new String("James Gosling");
String cloneName = new String(tName);