1. 程式人生 > >String length()函式,字母,漢字的長度都是1

String length()函式,字母,漢字的長度都是1

String length()函式
Returns the length of this string. The length is equal to the number of 16-bit Unicode characters in the string.
"aaa".length() = 3;
"你好呀".length() = 3;
"aaa你好呀".length() = 6;

JAVA採用Unicode,字母,漢字的長度都是1