The method codePointCount() returns the number of Unicode code points in the specified range. The text range begins at the first index and ends at the second index – 1.

Available Signatures

public int codePointCount(int beginIndex, int endIndex)


public void whenCallCodePointCount_thenCorrect() {
    assertEquals(2, "abcd".codePointCount(0, 2));


  • IndexOutOfBoundsException – if the first index is negative, the first index is greater than the second index or the second index is not less than the length of the String.
@Test(expected = IndexOutOfBoundsException.class)
public void whenSecondIndexEqualToLengthOfString_thenExceptionThrown() {
    char character = "Paul".charAt(4);
Next »
Java String.codePointAt()
« Previous
Java String.String()
Course – LS – All

Get started with Spring and Spring Boot, through the Learn Spring course:

res – REST with Spring (eBook) (everywhere)
Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.