【发布时间】:2013-12-08 08:37:07
【问题描述】:
我发现了一个棘手的地方,找不到任何答案为什么会发生这种情况。
主要问题是字符串有多长。
是否包含一个或两个字符。
代码:
public class App {
public static void main(String[] args) throws Exception {
char ch0 = 55378;
char ch1 = 56816;
String str = new String(new char[]{ch0, ch1});
System.out.println(str);
System.out.println(str.length());
System.out.println(str.codePointCount(0, 2));
System.out.println(str.charAt(0));
System.out.println(str.charAt(1));
}
}
输出:
?
2
1
?
?
有什么建议吗?
【问题讨论】:
-
我建议你花点时间去看看this article
-
你期待什么输出?