Java StringBuffer codePointBefore() Example

Java StringBuffer codePointBefore() method returns the character (Unicode code point) before the specified index. The index refers to char values (Unicode code units) and ranges from 1 to length.
This method throws the IndexOutOfBoundsException - if the index argument is negative or not less than the length of this string.

Java StringBuffer codePointBefore() Example

public class CodePointBeforeExample {
 public static void main(String[] args) {
  StringBuffer buffer = new StringBuffer("javaguides");
  int unicode = buffer.codePointBefore(1);
  System.out.println("the character (Unicode code point)"
    + "  at the before specified index is :: " + unicode);
 }
}
Output:
the character (Unicode code point) at the before specified index is :: 106

Comments