Logical Equality and Compare References

来源:互联网 发布:mac软件安装文件夹 编辑:程序博客网 时间:2024/05/10 15:24

In Java, == compares object references only. It doesn’t perform a logical equality check. You use the equals method for that purpose.

In contrast, Scala uses == for logical equality, but it calls the equals method. A new method, eq, is available when you want to compare references, but not test for logical equality.


Ref

《Programming Scala》

0 0