Home >>Java String Methods >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.
public int codePointBefore(int index)
index - This parameter is used to specified an int value, representing the index following the Unicode that should be returned
It returns an int value which is used to representing the Unicode value before the specified index
IndexOutOfBoundsException - Where index is negative, or not less than the specified string length
public class MyClass
{
public static void main(String[] args) {
String strln = "HelloWorld";
int result = strln.codePointBefore(1);
System.out.println(result);
}
}