Java StringBuffer codePointCount() Example

Java StringBuffer codePointCount() method returns the number of Unicode code points in the specified text range of this String. The text range begins at the specified beginIndex and extends to the char at index endIndex - 1.
This method throws IndexOutOfBoundsException - if the beginIndex is negative, or endIndex is larger than the length of this String, or beginIndex is larger than the endIndex.

Java StringBuffer codePointCount() Example

public class CodePointCountExample {
 public static void main(String[] args) {
  StringBuffer buffer = new StringBuffer("javaguides");
  System.out.println("length of the string :: " + buffer.length());
  int unicode = buffer.codePointCount(0, buffer.length());
  System.out.println("the character (Unicode code point) "
    + " at the specified index is :: " + unicode);
length of the string :: 10
the character (Unicode code point)  at the specified index is :: 10


Free Spring Boot Tutorial - 5 Hours Full Course

Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course