Tech article
Understanding == vs .equals() in Java: The Beginner's Trap That Cost Me Hours
Community description: When I first started learning Java, I wrote a simple login system. The password entered by the user...
Dev.to | Sep 12, 2026 | PRATHMESH KUMBHAR
Automated excerpt
When I first started learning Java, I wrote a simple login system. System. out. println(str1 == str2); // ❌ Prints FALSE Because the new keyword forces Java to create two completely separate objects in different memory locations. Because . equals() goes inside the object, compares it character-by-character (J-a-v-a), and confirms that the values are identical.
Selected automatically from source text; not independently written or fact-checked. Read the original for full context.