Hi All,
Can a
string literal have comments in it? JLS 3.7, it is mentioned as follows:
-------------------------------------------------------------
The lexical grammar implies that comments do not occur within character literals (�3.10.4) or string literals (�3.10.5).
-------------------------------------------------------------
But the following program compiles and runs perfectly:
class
Test {
public static void main(String args[])
{
String str1="This is a /*comment*/ string literal";
String str2="This is a //comment string literal";
System.out.println(str1);
System.out.println(str2);
}
}
Am i missing something?
Thanks in advance.