string.codePointBefore()
String.codePointBefore() Returns the unicode value of the character present before the input position of the string.
Syntax
String.codePointBefore(input)
input is an integer staring from 0 ( first position )
Here are some examples with output.
String my_str="Welcome to plus2net";
System.out.println(my_str.codePointBefore(1)); // 87
System.out.println(my_str.codePointBefore(3)); // 108
System.out.println(my_str.codePointBefore(15)); // 115
If we use input as 0 (first char is at position 0), then we will get error like this
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
Learn more about unicode values of the Chars here
« All String functions
This article is written by plus2net.com team.
plus2net.com