I just announced the new Spring 5 modules in REST With Spring:

>> CHECK OUT THE COURSE

This article is part of a series:
• Java String.String()
• Java String.codePointCount()
• Java String.codePointCount()
• Java String.codePointAt()
• Java String.concat()
• Java String.contains()
• Java String.copyValueOf()
• Java String.endsWith()
• Java String.format()
• Java String.getBytes()
• Java String.indexOf()
• Java String.intern()
• Java String.isEmpty()
• Java String.lastIndexOf()
• Java String.regionMatches()
• Java String.replace()
• Java String.replaceAll()
• Java String.split()
• Java String.startsWith()
• Java String.subSequence()
• Java String.substring()
• Java String.toLowerCase()
• Java String.toUpperCase()
• Java String.trim()
• Java String.valueOf()

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)

Example

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

Throws

  • 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);
}

I just announced the new Spring 5 modules in REST With Spring:

>> CHECK OUT THE LESSONS