Looking to gain a better understanding of .equals
vs ==
in java
In particular I was curious how these behave at the memory level?
Everything I've read so far states that ==
looks to see if the objects refer to the same memory location while .equals
will compare the content of the objects within a given memory location.
What is the advantage to comparing content versus the actual memory location? Is there any instances where .equals
would behave different from ==
or vice a versa?