๐ฌ Intro — “I Thought I Knew ==… Until Java Proved Me Wrong” I was casually writing: Integer a = 128; Integer b = 128; System.out.println(a == b); // Output: false ❌ …and confidently told myself: “Yeah, that’s definitely true.” ๐ฅ WRONG! Output: false I was like… ๐ง♂️ “Hello? Java, are you okay?” Let's break this down, and I’ll show you what I learned — in my usual style: with humor, diagrams, dumb-but-smart questions, and gotchas! ๐งช 1. Code Examples That Confused Me ✅ Primitive Comparison Works int a = 128; int b = 128; System.out.println(a == b); // true ✅ ➡️ Simple! Both values are 128, both stored in stack. Done. ❌ Object Comparison Fails? Integer a = 128; Integer b = 128; System.out.println(a == b); // false ❌ ➡️ Wait, same values, but still false? ✅ Mixed (Object + Primitive) Integer a = 128; int b = 128; System.out.println(a == b); // true ✅ ➡️ What? Now it works again?
A cozy space where I share my daily Java learnings, issues, and solutions.