Java if-else-if ladder Statement


The if-else-if ladder statement executes one condition from multiple statements.

Syntax:

    if(condition1){  
    //code to be executed if condition1 is true  
    }else if(condition2){  
    //code to be executed if condition2 is true  
    }  
    else if(condition3){  
    //code to be executed if condition3 is true  
    }  
    ...  
    else{  
    //code to be executed if all the conditions are false  
    }  

ifelseif