Java String codePointCount() Metoda
Przykład
Zwróć liczbę wartości Unicode znalezionych w ciągu:
String myStr = "Hello";
int result = myStr.codePointCount(0, 5);
System.out.println(result);
Definicja i użycie
Metoda codePointCount()
zwraca liczbę wartości Unicode znalezionych w ciągu.
Użyj parametrów startIndex i endIndex , aby określić, gdzie rozpocząć i zakończyć wyszukiwanie.
Indeks pierwszego znaku to 0, drugi znak to 1 i tak dalej.
Składnia
public int codePointCount(int startIndex, int endIndex)
Wartości parametrów
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 |
Szczegóły techniczne
Zwroty: | Wartość int reprezentująca liczbę wartości Unicode znalezionych w ciągu |
---|---|
Rzuty: | IndexOutOfBoundsException - jeśli startIndex jest ujemny lub endindex jest większy niż długość ciągu lub startIndex jest większy niż endIndex |
Wersja Java: | 1,5 |
❮ Metody strunowe