bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java String codePointCount() Method

❮ String Methods

Example

String myStr = "Hello";
int result = myStr.codePointCount(0, 5);
System.out.println(result);

Definition and Usage

The codePointCount() method returns the number of Unicode values found in a string.

Use the startIndex and endIndex parameters to specify where to begin and end the search.

The index of the first character is 0, the second character is 1, and so on.

Syntax

public int codePointCount(int
startIndex , int
endIndex )

Parameter Values

ParameterDescription
startIndexAn int value, representing the index to the first character in the string
endIndexAn int value, representing the index after the last character in the string

Technical Details

Returns:An int value, representing the number of Unicode values found in a string
Throws:IndexOutOfBoundsException - if startIndex is negative, or endindex is larger than the length of the string, or startIndex is larger than endIndex
Java Version:1.5

Previous

Java String codePointBefore() Method

Next

Java String compareTo() Method