/* */ Click to Join Live Class with Shankar sir Call 9798158723

If else statement in Java

In If Statement the statement is executed when the condition is true otherwise statement will be skips. Means that when we want to execute some other block of code if the condition is false.we can use the if else statement in Java. it menas that when the condition was true it execute IF block otherwish executed Else block when the condition is false.

Syntex :-

        // if condition is true then if statement is executed.
        //if condition is flase then Else statement is executed

Q.) W.A.P to print odd or even number ?
//It is a program of odd and even number.  
public class IfElseExample {  
public static void main(String[] args) {  
    //defining a variable  
    int number=22;  
    //Check if the number is divisible by 2 or not  
        System.out.println("even number");  
        System.out.println("odd number");  
even number