what is the difference between == operator and equals()? (with hashcode() ???)
I was learning hashcode in more depth and figured that: 1. If you override equals(), you must override hashcode() too. 2. To find if 2 objects are same object, use == operator Given those 2 factors, in Java I was assuming that when == operator is used to compare if 2 instances are same or not, if(object1 == object2) is actually doing if(object1.hashcode() == object2.hashcode()) But it appears I was wrong by running the test below. public class Main { public static void main(String[] args){ Obj1 one = new Obj1(); Obj1 two = new Obj1(); //is this calling hashCode() in backend??? if(one == two) {