Friday 4 July 2014

codePointCount (int beginIndex, int endIndex)

public synchronized int codePointCount(int beginIndex, int endIndex)
Returns the number of Unicode code points in the specified text range of this sequence.

public class StringBufferCodePointCount {
    public static void main(String args[]){
        int arr[] = {65536, 65537, 65538};
        String s = new String(arr, 0, arr.length);
        
        StringBuffer str = new StringBuffer(s);
        
        System.out.print("Code points count from 0 to " + str.length());
        System.out.println(" is "+ str.codePointCount(0, str.length()));
    }
}

Output
Code points count from 0 to 6 is 3





Prevoius                                                 Next                                                 Home

No comments:

Post a Comment