Java的String类的内部其实维护的是一个char数组,查看[jdkdoc](https://docs.oracle.com/javase/7/docs/api/java/lang/String.html)可知: length()方法即返回返回这个数组里面char的个数。Returns the length of this string. public int codePointCount(int beginIndex, int endIndex)
Returns the number of Unicode code points in the specified text range of this String. The text range begins at the specified beginIndex and extends to the char at index endIndex - 1. Thus the length (in chars) of the text range is endIndex-beginIndex. Unpaired surrogates within the text range count as one code point each.
Java的
String类的内部其实维护的是一个char数组,查看[jdkdoc](https://docs.oracle.com/javase/7/docs/api/java/lang/String.html)可知:length()方法即返回返回这个数组里面char的个数。Returns the length of this string.public int codePointCount(int beginIndex, int endIndex)即返回这个string类中起始到终止位置的字符串。