[Java] The difference between equals and ==

前置说明:equals和==的区别
Java 语言里的 equals方法其实是交给开发者去覆写的,让开发者自己去定义满足什么条件的两个Object是equal的。

A picture is worth a thousand words

Insert picture description here


The difference between equals and ==

== equals
Determine whether two variables or instances point to the same memory space Determine whether the values ​​of the memory spaces pointed to by two variables or instances are the same
Compare memory addresses Compare the contents of the string
Are the references the same Are the values ​​the same
Published 99 original articles · Like 106 · Visit 270,000+

Guess you like

Origin blog.csdn.net/lglglgl/article/details/104973047