+2 votes
in JAVA by
What's the difference between "a == b" and "a.equals(b)"?

1 Answer

0 votes
by

The a = b does object reference matching if both a and b are an object and only return true if both are pointing to the same object in the heap space, on the other hand, a.equals(b) is used for logical mapping and its expected from an object to override this method to provide logical equality. For example, String class overrides this equals() method so that you can compare two Strings, which are the different object but contains same letters.

Related questions

+1 vote
asked Jan 24, 2020 in JAVA by rahuljain1
+1 vote
asked May 29, 2020 in JAVA by Hodge
...