What is the equals() method?
What is the equals() method?
Rating:
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.
Rating:
Other articles
- Modifiers
- What is the DateFormat class?
- What is the public access specifier?
- Things to practice for Sun test CX310-036.
- How does the JNDI locate the home interface of an enterprise bean?