Java-If Else Statement

If Else Statement

The ‘if else’ statement is an extension of the simple if statement. The general form of a ‘if else’ statement is :

The ‘statement-block’ may be a single statement or a group of statements. If the test expression is true, the statement-block will be executed; If the test expression is false, the else-statement-block will be executed.

Program

Program Source

class Javaapp {

    public static void main(String[] args) {
        
        if(true)
        {
            System.out.println("Condition : True");
        }else
        {
            System.out.println("Condition : False");
        }
        
        if(10>20)
        {
            System.out.println("10 Greater than 20 : True");
        }else
        {
            System.out.println("10 Greater than 20 : False");
        }
    }
}

Leave a Comment