class Why
{
public static void main(String[]s)
{
String st2="A";
System.out.println(st2);
// String st4="MN3444\u000ar4t4";
System.out.println(st4);
}
}
请编译上面的代码,我在注释行中收到错误。
我无法理解编译器的这种行为, 这个错误是什么意思?
最佳答案
在编译之前,每个 Unicode 字符都被其值替换,因为 \u000a
代表换行代码
// String st4="MN3444\u000ar4t4";
与此代码相同(注意 \u000a
之后的文本将移至新行,这意味着它将不再是注释的一部分)
// String st4="MN3444
r4t4";
你可以用
来测试它//\u000a;System.out.println("hello comment");
等于
//
System.out.println("hello comment");
并且会给你作为结果输出:hello comment
关于java - java注释中如何读取unicode字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20302691/