What's the difference between the == operator and the equals() method? What test does Object.equals() use, and why?
The == operator would be used, in an object sense, to see if the two objects were actually the same object. This operator looks at the actually memory address to see if it actually the same object. The equals() method is used to compare the values of the object respectively. This is used in a higher level to see if the object values are equal. Of course the the equals() method would be overloaded in a meaningful way for whatever object that you were working with.
-
Interview Candidate
- Aug 28th, 2004
- 3
- 2465
Showing Answers 1 - 3 of 3 Answers
What's the difference between the == operator and the equals() method? What test does Object.equals() use, and why?