// \u represent unicode sequence
char c = '\u0045';
System.out.println(c);
Code is only this much and eclipse is showing following error message
"Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Invalid unicode
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.
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.
To fix it, you can write
// \\u represent unicode sequence (extra backslash for escaping)
or
// \ u represent unicode sequence (extra whitespace for escaping)
Edit:
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");
}
}
outputs Hi, because \u000A
stands for newline. Proof
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With