Java if else if ladder Example


Java if-else statement is used to check condition whether it is true or false. If the first condition is false then it will check the next condition, if the next condition also false, then it will finally run the else condition.

Program
public class Ifelsecondition{ public static void main(String args[]){ int x=6; if(x>6){ System.out.println("if this condition true it will run (x>6) block,else next"); } else if(x<6){ System.out.println("if this condition true it will run (x<6)) block,else next"); } else{ System.out.println("else this block run ,if all condition get false"); } }}
Input
Output