How to get the number of Unicode code points in subarray of char array in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {
 
    public static void main(String[] args) {
        
        String s = "Java Programming";
        
        // codepoint from index 1 to index 6
        int cp = s.codePointCount(1, 6); // codePointCount(char[] a, int offset, int count)
        
        System.out.println(cp);
    }
}
 
/*
run:

5
 
*/

 



answered Sep 12, 2016 by avibootz
...