Given:
char x = '"';
char y = '\"';开发者_如何学Python
Are x and y equal?
They are equal. (the link executes the following test)
class foo{
public static void main(String[] a){
System.out.println('"' == '\"'); // prints true
}
}
I didn't feel like running code so I just googled...
JLS 3.10.6 Escape Sequences for Character and String Literals
...and if your javac doesn't conform then it's broken and not my fault :)
The keywords I used were "JLS" (for Java Language Specification) and "character literals" (because that's what '?'
is).
Yes.
class Test {
public static void main (String[] args) {
char x = '"';
char y = '\"';
boolean equal = (x == y);
System.out.println("x == y ?" + equal);
}
}
The output is true
. Seems pretty conclusive.
精彩评论