obj2 = true only if both has same memory location.
on the other hand equals() is a method defined in Object class and has overridden in many classes including String, Integer and provides logical equality e.g. two strings are equal by equals() method if there content are same.
Copyright © 2026 eLLeNow.com All Rights Reserved.