Metoda Java String codePointCount().
Příklad
Vrátí počet hodnot Unicode nalezených v řetězci:
String myStr = "Hello";
int result = myStr.codePointCount(0, 5);
System.out.println(result);
Definice a použití
Metoda codePointCount()
vrací počet hodnot Unicode nalezených v řetězci.
Pomocí parametrů startIndex a endIndex určete, kde začít a ukončit vyhledávání.
Index prvního znaku je 0, druhý znak je 1 a tak dále.
Syntax
public int codePointCount(int startIndex, int endIndex)
Hodnoty parametrů
Parameter | Description |
---|---|
startIndex | An int value, representing the index to
the first character in the string |
endIndex | An int value, representing the index
after the last character in the string |
Technické údaje
Vrácení: | Hodnota int představující počet hodnot Unicode nalezených v řetězci |
---|---|
Hody: | IndexOutOfBoundsException - pokud je startIndex záporný nebo endindex je větší než délka řetězce nebo startIndex je větší než endIndex |
Verze Java: | 1.5 |
❮ Metody řetězců