π 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 {