'==' vs '.equals()': A common interview trap
This distinction catches many freshers off guard.
For primitive types, == performs value comparison. But for objects, it only checks if two references point to the same memory address. To compare object values properly, use .equals(), many classes override this method to provide meaningful comparisons.
5March 10, 2026 2K 2