When we write the following code in Java:
object1 == object2;
on what basis does the operator '==' decide equality?
Answer
If object1
and object2
are reference types, then ==
checks if object1
and object2
are both references to the same object.
See 15.21 Equality Operators in the Java Language Specification for full details.
No comments:
Post a Comment