Java Data Type Tutorial - Java String.codePointBefore(int index)








Syntax

String.codePointBefore(int index) has the following syntax.

public int codePointBefore(int index)

Example

In the following code shows how to use String.codePointBefore(int index) method.

public class Main {
/*from   ww w.ja va2s  . c  o  m*/
  public static void main(String[] args) {
  
    String str = "java2s.com";
    System.out.println("String = " + str);
        
    // codepoint before index 1 i.e j
    int retval = str.codePointBefore(1);
        
    // prints character before index1 in string
    System.out.println("Character(unicode point) = " + retval);
  }
}

The code above generates the following result.