Java Manual string
String ()
-
Initializes a newly created
String object so that it represents a sequence of empty characters. Note that because the String is immutable, you do not need to use this construction method.
String
String (String original)
-
Initializes a newly created
String object to represent a sequence of characters that are the same as the argument; in other words, the newly created string is a copy of the parameter string. Because the String is immutable, you do not need to use this construction method unless you want
original an explicit copy.
-
Parameters:
-
original -a
String .
String
String (char[] value)
-
Assigns a new sequence of characters that is
String currently contained in the character array parameter. The contents of the character array have been copied, and subsequent modifications to the character array do not affect the newly created string.
-
Parameters:
-
value -Initial value of the string
String
String (char[] value, int offset, int count)
-
Assigns a new
String character that contains a subarray of characters taken from the character array parameter. The
offset parameter is the index of the first character of the Subarray, and the
count parameter specifies the length of the sub-array. The contents of the Subarray have been copied, and subsequent modifications to the character array do not affect the newly created string.
-
Parameters:
-
value -as an array of character mnemonic.
-
offset -Initial offset amount.
-
count -length.
-
Thrown:
-
IndexOutOfBoundsException -If
offset and
count parameter index characters exceed
value the range of the array.
Instance:
public class ToString { public static void main (string[] args) { /span>char [] cs = {' d ', ' e ', ' g ', ' Y ', ' C ', ' R ', ' n ', ' u ', ' a ', ' u '
Operation Result:
Degycrnuauycrnu
Java array type go to String type