Java String codePointCount() Metode
Voorbeeld
Wys die aantal Unicode-waardes wat in 'n string gevind is:
String myStr = "Hello";
int result = myStr.codePointCount(0, 5);
System.out.println(result);
Definisie en gebruik
Die codePointCount()
metode gee die aantal Unicode-waardes terug wat in 'n string gevind word.
Gebruik die startIndex en endIndex parameters om te spesifiseer waar om die soektog te begin en te beëindig.
Die indeks van die eerste karakter is 0, die tweede karakter is 1, ensovoorts.
Sintaksis
public int codePointCount(int startIndex, int endIndex)
Parameterwaardes
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 |
Tegniese besonderhede
Terugsendings: | 'n int Waarde wat die aantal Unicode-waardes verteenwoordig wat in 'n string gevind word |
---|---|
Gooie: | IndexOutOfBoundsException - as startIndex negatief is, of endindex is groter as die lengte van die string, of startIndex is groter as endIndex |
Java weergawe: | 1.5 |
❮ Stringmetodes