How to get the code point preceding (before) the given index of char array in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {
 
    public static void main(String[] args) {
        
        String s = "Java Programming";

        // the codepoint before index 2
        int cp = s.codePointBefore(2); // codePointBefore(char[] a, int index)
        System.out.println(cp);
        
        // the codepoint before index 6
        System.out.println(s.codePointBefore(6));
    }
}
 
/*
run:

97
80
 
*/

 



answered Sep 12, 2016 by avibootz
...