class k{
public static void main(String[] args) {
//('\u000d');
}
}
In class k after main i have commented out line number 3 but still getting error unclosed character literal ,what could be the reason for it?
class k{
public static void main(String[] args) {
//('\u000d');
}
}
In class k after main i have commented out line number 3 but still getting error unclosed character literal ,what could be the reason for it?
Unicode characters are parsed very early in the Java compilation, anyway \u000d
isn't a valid character.
// The other style comments work.
/*('\u000d'); */
Edit
\u000d is converted into a newline, which ends your comment...
//('\u000d');
gets converted into
//('
') // <-- bare line with ')
which isn't a valid character constant.
It appears that '\u000d'
is a newline character. The compiler sees the single line of code as two lines:
//('
');
This is why you get the error. The second line has an opening single-quote, but no closing one to match.
It's a character literal. \u000d
means "newline". While being in a commented line may seem to you like nothing in it is handled, this happens:
original : {
//('\u000d');
}
pre-compile : {
//('
'); // <- This is syntax error!!!
}