DEV Community

Saravanan
Saravanan

Posted on

1

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)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay