Easy learning with example program codes

If Else If Statement in Java

If else statement is used to execute one block of statements from many depends upon the condition. If condition1 is true then block of statements1 will be executed, else if condition2 is true block of statements2 is executed and so on. If no condition is true, then else block of statements will be executed.


   //Block of statements1.
}else if(condition2){
   //Block of statements2.
else if(conditionn){
   //Block of statementsn.
 //Block of statements.

Program to use if else if statement in Java.

 * Program to use if else if statement in Java program.
 * @author codesjava
public class IFELSEIFExample {	
	public static void main(String args[]){ 
		int num = 10;
		if(num == 10){
	          System.out.println("num is equal to 10.");
		}else if(num > 10){
	          System.out.println("num is greater than 10.");
		  System.out.println("num is less then 10.");


num is equal to 10.


Please follow and like us:
Posted in Java   

Copyright © 2019 CodesJava Protection Status