== — checks if two references point to the same object in memory. equals() — checks if two objects are logically equal.Vivid analogy: Two identical novels in different libraries. == asks "Is this the exact same physical book?" (No). .equals() asks "Do these books contain the same story?" (Yes).Why it matters: Misusing == for object comparison leads to subtle, intermittent bugs — especially with Strings where pooling makes == work sometimes but fail when objects come from different sources.javaString s1 = new String("hello");String s2 = new String("hello");s1 == s2; // false — different objects on heaps1.equals(s2); // true — same character sequenceString s3 = "hello";String s4 = "hello";s3 == s4; // true — both reference same pool objects3.equals(s4); // true — same contentclass Point { int x, y; Point(int x, int y) { this.x = x; this.y = y; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Point)) return false; Point p = (Point) o; return x == p.x && y == p.y; }}- == — reference identity and null checks.- equals() — logical/content equality.