Java If-else StatementThe Java if statement is used to test the condition. It checks boolean condition: true or false. There are various types of if statement in java.
Java if StatementThe Java if statement tests the condition. It executes the if block if condition is true. Syntax: ![]() Example: Test it NowOutput: Age is greater than 18 Java if-else StatementThe Java if-else statement also tests the condition. It executes the if block if condition is true otherwise else block is executed. Syntax: ![]() Example: Test it NowOutput: odd number Java if-else-if ladder StatementThe if-else-if ladder statement executes one condition from multiple statements. Syntax: ![]() Example: Output: C grade Java Nested if statementThe nested if statement represents the if block within another if block. Here, the inner if block condition executes only when outer if block condition is true. Syntax: ![]() Example: Test it NowOutput: You are eligible to donate blood Example 2: Test it NowOutput: You are not eligible to donate blood
Next TopicJava Switch Statement
|