更新时间:2022-06-22 05:39:37
在 Java 中,A == B
和 B == A
始终具有相同的语义.在 C#(具有运算符重载)中,如果 B
是 A
类的子类的实例,则可能会有所不同.
In Java, A == B
and B == A
always have the same semantics. In C# (which has operator overloading), there can be a difference if, say, B
is an instance of a subclass of the class of A
.
请注意,A.equals(B)
不等同于 A == B
.
Note that A.equals(B)
is not equivalent to A == B
.