Home >>Java String Methods >Java String codePointCount() Method
The codePointCount() method in Java String is used to returns the number of Unicode values found in a string.
You can also use the parameters startIndex and endIndex to specify where to begin and end the search.
public int codePointCount(int startIndex, int endIndex)
startIndex -This parameter is used to specifies an int value, to representing the index to the first character in the string
endIndex - It is used to representing an int value, the index after the last character in the string
It is used to represents an int value at the number of Unicode values found in a string
IndexOutOfBoundsException - If startIndex is negative or endindex greater than the string length, or startIndex greater than endIndex
public class MyClass
{
public static void main(String[] args)
{
String strln1 = "Phptpoint";
int result = strln1.codePointCount(0, 8);
System.out.println(result);
}
}