Back to articles
πŸš€ Day 26 of My Automation Journey – Conditions, Inputs & Do-While Loop

πŸš€ Day 26 of My Automation Journey – Conditions, Inputs & Do-While Loop

via Dev.to Beginnersbala d kaveri

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 debug

Continue reading on Dev.to Beginners

Opens in a new tab

Read Full Article
6 views

Related Articles