代码只是这么多,eclipse显示以下错误消息
Code is only this much and eclipse is showing following error message
"Exception in thread "main" java.lang.Error: Unresolved compilation problem: Invalid unicode现在,当我从评论中删除 \u 时它工作正常,有什么问题? code> \ u 评论?这是一个错误还是有一些关系,因为认为Java应该保留评论。
Now when I remove \u from comment it is working fine, what is the problem with \u in comment? IS this a bug or there is some relation, as far as think Java should leave the comments as it is.
推荐答案编译器会首先读取你的整个源代码(稍后会忽略注释),但是他无法识别\ u,因为它不是有效的unicode-character。
The compiler will read your entire source code first (the comment will be ignored later), but he can't recognize "\u ", because it is no valid unicode-character.
要修复它,你可以写
// \\u represent unicode sequence (extra backslash for escaping)或
// \ u represent unicode sequence (extra whitespace for escaping)编辑: 这是因为编译器首先将所有内容翻译成unicode。编写这个简单的程序
This is because the compiler translates everything into unicode first. Writing this simple programm
class Ideone { public static void main (String[] args) { // \u000A System.out.println("Hi"); } }输出嗨,因为 \ u000A 代表换行符。 证明
outputs Hi, because \u000A stands for newline. Proof
更多推荐
Java注释中的\ u导致错误信息,为什么?
发布评论