🚀 Day 26 of My Automation Journey – Conditions, Inputs & Do-While Loop
Today’s session was a mix of core Java fundamentals + tricky logic + real-world usage 💡 We explored how conditions work, how loops behave without braces, user input handling, and even touched JSON...

Source: DEV Community
Today’s session was a mix of core Java fundamentals + tricky logic + real-world usage 💡 We explored how conditions work, how loops behave without braces, user input handling, and even touched JSON/XML basics. Let’s break it down step by step 👇 🔹 1. Condition Must Be Boolean (True/False) In Java, every condition must return either true or false. ❌ Invalid Example int i = 1; while(i) { // ❌ Compilation Error System.out.println(i); } 👉 Why error? Java does NOT allow non-boolean conditions Unlike C/C++, numbers are not treated as true/false ✅ Correct Example int i = 1; while(i <= 5) { System.out.println(i); i++; } ✔ Condition → i <= 5 → returns boolean ✔ Hence valid 🔹 2. True / False Direct Conditions You can directly use true or false in conditions. ✅ Example if(true) { System.out.println("Always runs"); } ✔ Output: Always runs ❌ Example if(false) { System.out.println("Never runs"); } ✔ Output: (no output) 👉 This is useful for testing or debugging 🔹 3. Removing Curly Braces {