如果x==y是true这样y==x应该true是不是这样的情况?
但我发现了这个说法:
反向不是必须的
请在这件事上给予我帮助?
如果x和y是String对象和x == y是true,然后x.equals(y)也true.
但
如果x.equals(y)是true那么x == y可能false.
请考虑以下示例:
String x = "abc";
String y = new String("abc");
System.out.println(x == y); //false
System.out.println(x.equals(y)); //true
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
573 次 |
| 最近记录: |