In this tutorial, you’ll learn about Java if else ladder Statement and how to use it in Java Programs.
In the cases of Java ef else ladder when we have multiple conditions and only one has to be selected in that case we can use an if else ladder.
Syntax
if(condition1){
//code to be executed if condition1 is true
}else if(condition2){
//code to be executed if condition2 is true
}
……
else{
//code to be executed if all condition are false
}
Below is the flow chart showing how if else Ladder works.

Program to check given number is positive, negative or 0.
public class IFLadderDemo{
public static void main(String []args){
int number=-17;
if(number>0){
System.out.println("Number is positive");
}else if(number<0){
System.out.println("Number is Negative");
}else{
System.out.println("Number is 0");
}
}
}
Output
Number is Negative
In the above program, we check that the given number is positive or negative or 0 using if else ladder.
Ask your questions about Java control flow if else Ladder statement and clarify your/others doubts by commenting. Documentation.
Please write to us at [email protected] to report any issue with the above content or for feedback.
This tutorial is contributed by Ashutosh Sahu
PREVIOUS JAVA IF..ELSE STATEMENT | NEXT JAVA NESTED IF ELSE STATEMENT |