Metoda Java String copyValueOf().
Příklad
Vraťte řetězec, který představuje určité znaky pole znaků:
char[] myStr1 = {'H', 'e', 'l', 'l', 'o'};
String myStr2 = "";
myStr2 = myStr2.copyValueOf(myStr1, 0, 5);
System.out.println("Returned String: " + myStr2);
Definice a použití
Metoda copyValueOf()
vrací a String
, které představuje znaky pole char.
Tato metoda vrátí nové String
pole a zkopíruje do něj znaky.
Syntax
public static String copyValueOf(char[] data, int offset, int count)
Hodnoty parametrů
Parameter | Description |
---|---|
data | A char array |
offset | An int value, representing the start
index of the char array |
count | An int value, representing the length
of the char array |
Technické údaje
Vrácení: | A String , představující znaky pole char |
---|---|
Hody: | StringIndexOutOfBoundsException - pokud je offset záporný nebo mimo dosah, nebo pokud je počet větší než délka pole znaků, nebo záporný |
❮ Metody řetězců