Home >>Java String Methods >Java String codePointBefore() Method

Java String codePointBefore() Method

Java String codePointBefore() Method

The codePointBefore() method in Java String is used to returns the Unicode value of the character before the specified index (The first character is 1, the second character is 2, and so on) in a string.

Syntax

public int codePointBefore(int index)

Parameter

index - This parameter is used to specified an int value, representing the index following the Unicode that should be returned

Returns

It returns an int value which is used to representing the Unicode value before the specified index

Throws

IndexOutOfBoundsException - Where index is negative, or not less than the specified string length

Java String codePointBefore() method example 1

public class MyClass 
{
  public static void main(String[] args) {
    String strln = "HelloWorld";
    int result = strln.codePointBefore(1);
    System.out.println(result);
  }
}

72

No Sidebar ads