Continuous Test Orchestration And Execution Platform Online

Perform automated and live-interactive testing on 3000+ real desktop and mobile devices online.

Write a Java program to demonstrate nested if …else statement?

The if-else statement executes a block of statements if a condition is true. If the specified condition is false, it executes another block of statements. The if-else statement comes under JavaScript's conditional statements, which can be used to perform specified actions based on different conditions.

Syntax


if(condition){  
//execute the statement if condition is true  
}
else{  
//execute the statement if condition is false 
}  

Code Example

The below Java program checks whether a number is even or odd.


public class EvenOdd {  
public static void main(String[] args) {  
    int num=12;  
    if(num%2==0){  
        System.out.println("Even Number");  
    }
    else{  
        System.out.println("Odd Number");  
    }  
}  
}  
LambdaTest

Test your websites, web-apps, or mobile apps seamlessly with LambdaTest.

Start Free Testing
LambdaTest

Earn resume-worthy Selenium certifications that help you land a top job.

Learn More
LambdaTest

Test your web or mobile apps

Test orchestration and execution cloud of 3000+ browsers and OS

Support

24/7 support

Security

Enterprise grade security

Cloud

Fastest test execution cloud