I came across the following code:
public class LinePrinter {
public static void main(String args[]) {
//Note: \u000A is unicode for Line Feed
char c=0x000A;
System.out.println(c);
}
}
This doesn't compile due to the Unicode replacement done.
The question is, why doesn't the comment (//
) override Unicode replacement done by the compiler? I thought the compiler should ignore the comments first before doing anything else with the code translation.
EDIT:
Not sure if the above is clear enough.
I know what happens with the above and why it errors out. My expectation is that the compiler should ignore all the commented lines before doing any translation with the code. Obviously that's not the case here. I am expecting a rationale for this behaviour.