Strings – Oracle documentation and tutorial

     String str = "abc";

is equivalent to:

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

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.

The different ways to declare an array in Java


The following from:

The [] may appear as part of the type at the beginning of the declaration, or as part of the declarator for a particular variable, or both.

For example:

byte[] rowvector, colvector, matrix[];

This declaration is equivalent to:

byte rowvector[], colvector[], matrix[][];