Wednesday, 12 July 2017

Difference between == operator and .equals( ) method in Java

In general we use == operator for reference comparison, whereas .equals( ) method for content comparison.

.equals( ) method is present in the object class also meant for reference comparison only based on our requirement we can override for content comparison.

In String class, all wrapper classes and all collection classes .equals( ) method is overridden for content comparison.

If you like the post, please comment, share the post and do like me on Facebook.
Thanks & Regards,
Susanto Paul