Asked by Samuel Flores on Apr 24, 2024
Verified
When used with objects,what is the equality == )operator really comparing?
Equality Operator
A binary operator that compares two values for equality and returns a boolean result.
Objects
Objects are instances of classes in object-oriented programming that contain both data (attributes) and behaviors (methods) defined by their respective classes.
- Understand object equality and comparison in Java.
Verified Answer
ZK
Zybrea KnightMay 02, 2024
Final Answer :
The == operator does not check that the objects have the same values for instance variables.It checks for equality of memory address,so two objects in two different locations in memory would test as being "not equal" when compared using ==,even if their instance variables contain equivalent data.
Learning Objectives
- Understand object equality and comparison in Java.