且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

A==B vs B==A,有什么区别

更新时间:2022-06-22 05:39:37

在 Java 中,A == BB == A 始终具有相同的语义.在 C#(具有运算符重载)中,如果 BA 类的子类的实例,则可能会有所不同.

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.