Java String.codePointCount(int beginIndex, int endIndex)
Syntax
String.codePointCount(int beginIndex, int endIndex) has the following syntax.
public int codePointCount(int beginIndex, int endIndex)
Example
In the following code shows how to use String.codePointCount(int beginIndex, int endIndex) method.
//from ww w. j av a 2s. com
public class Main {
public static void main(String[] args) {
String str = "java2s.com";
System.out.println("String = " + str);
// codepoint from index 1 to index 8
int retval = str.codePointCount(1, 8);
// prints character from index 1 to index 8
System.out.println("Codepoint count = " + retval);
}
}
The code above generates the following result.