DEV Community

Saravanan
Saravanan

Posted on

Examples for condition statement,if,if else,else if


```package program_basics;

public class Condition_statement {

public static void main(String[] args) {
    // TODO Auto-generated method stub
Enter fullscreen mode Exit fullscreen mode

//-------------------------------------------------
//if only
/*
int i=25;
int j=50;

    if (i<j)
    {
        System.out.println("j is greater");

    }
    */
Enter fullscreen mode Exit fullscreen mode

//-----------------------------------------------
//if else only
/*
int i=25;
int j=50;

    if (i>j)
    {
        System.out.println("j is greater");

    }
    else 
    {
        System.out.println("j is lesser");

    }
    */
Enter fullscreen mode Exit fullscreen mode

//----------------------------------------------------

//else if only
/*
int i=35;
int j=50;

    if (i>j)
    {
        System.out.println("i is greater");
    }
    else if(j<i)
    {
        System.out.println("j is greater");
    }
    else
    {
        System.out.println("this is false");
    }
    */
}
Enter fullscreen mode Exit fullscreen mode

}



Enter fullscreen mode Exit fullscreen mode

Top comments (0)