JDK 1.5 , - Unicode 4.0
, char, 16 . code point – char-, code unit. String.length char- . 2 char-, String.length , . :
int codePointCount(int beginIndex, int endIndex)
code points unicode .
n- , String.charAt() – n- char. :
int offset = str.offsetByCodePoints(0, 3);
int codePnt = str.codePointAt(offset);
char-, 3- . ( char-) .
, , char- :
String str = "\uD800\uDF30";
System.out.println("str: " + str);
System.out.println("str.length(): " + str.length());
System.out.println("str.codePointCount(0, str.length()): " + str.codePointCount(0, str.length()));
System.out.println("str.charAt(0): " + (int)str.charAt(0));
System.out.println("str.charAt(1): " + (int)str.charAt(1));
System.out.println("str.codePointAt(0): " + str.codePointAt(0));
System.out.println("str.codePointAt(1): " + str.codePointAt(1));
: Unicode 4.0 , – , char, JDK 1.5 -char- . , Java C++, , .
, , .
: