SCJP Certification

Sun Certified Java Programmer Certification exam essentials

March 6th, 2010

What is the equals() method?

SCBCD, Uncategorized, by Daisy Williams.

The equals() method checks if some other object passed to it as an argument is equal to the object on which this method is invoked. The default implementation of the equals() method is in the Object class, the mother of all classes in Java. The equals() method in the Object class checks if two object references refer to the same object, i.e., it checks the referential equality of the two object references. This comparison is also known as shallow comparison.

Other classes in Java provide their own implementation of the equals() method. The classes providing their own implementations of the equals() method perform a deep comparison, i.e., the equals() method in these classes checks if the values of the objects are the same.

Share

Back Top

Responses to “What is the equals() method?”

Comments (0) Trackbacks (0) Leave a comment Trackback url
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Your email address will not be published. Required fields are marked *

*