Strings – Oracle documentation and tutorial

     String str = "abc";

is equivalent to:

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);

https://docs.oracle.com/javase/7/docs/api/java/lang/String.html

https://docs.oracle.com/javase/tutorial/java/data/strings.html

Strings are constant; their values cannot be changed after they are created.

getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)

Copies characters from this string into the destination character array.

See the tutorial above to see how the getChars String method can be used to create an array of char from a string, and the array can then be used to make a new string, thus in effect copying a string.

But also see this String method:

toCharArray() Converts this string to a new character array.

Leave a Reply