PrepZone Logo
PrepZone
Back to Java

Java · Easy

Difference between == and .equals(). When should each be used?

JavaCore Java

Answer preview

== (reference equality) — Compares whether two references point to the exact same object in memory. For primitives, it compares values directly.…