---
title: "Can you tell the difference between equals() method and equality operator (==) in Java?"  
description: "Can you tell the difference between equals() method and equality operator (==) in Java?"  
author: "Mukul Goenka"  
published: 2021-11-23  
canonical: https://www.mindstick.com/interview/33845/can-you-tell-the-difference-between-equals-method-and-equality-operator-in-java  
category: "java"  
tags: ["c#", "java", "programming language"]  
reading_time: 2 minutes  

---

# Can you tell the difference between equals() method and equality operator (==) in Java?

\

| ## equals() | **==** |
| --- | --- |
| This is a method defined in the Object class. | It is a binary operator in Java. |
| This method is used for checking the equality of contents between two objects as per the specified business logic. | This operator is used for comparing addresses (or references), i.e checks if both the objects are pointing to the same memory location. |

**Note.**\

- In the cases where the equals method is not overridden in a class, then the class uses the default implementation of the equals method that is closest to the parent class.
- Object class is considered as the parent class of all the java classes. The implementation of the equals method in the Object class uses the == operator to compare two objects. This default implementation can be overridden as per the business logic.

## Answers

### Answer by Mukul Goenka

\

| ## equals() | **==** |
| --- | --- |
| This is a method defined in the Object class. | It is a binary operator in Java. |
| This method is used for checking the equality of contents between two objects as per the specified business logic. | This operator is used for comparing addresses (or references), i.e checks if both the objects are pointing to the same memory location. |

**Note.**\

- In the cases where the equals method is not overridden in a class, then the class uses the default implementation of the equals method that is closest to the parent class.
- Object class is considered as the parent class of all the java classes. The implementation of the equals method in the Object class uses the == operator to compare two objects. This default implementation can be overridden as per the business logic.


---

Original Source: https://www.mindstick.com/interview/33845/can-you-tell-the-difference-between-equals-method-and-equality-operator-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
