Home > Java > javaTutorial > Examples for condition statement,if,if else,else if

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

Linda Hamilton
Release: 2025-01-29 22:04:11
Original
175 people have browsed it
<code class="language-java">package program_basics;

public class Condition_statement {

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

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

        if (i<j)
        System.out.println("i is lesser");
        */

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

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

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

        }
        */


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

        //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 lesser");
        }
        else
        {
            System.out.println("i and j are equal");
        }
        */
    }
}</code>
Copy after login

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

This revised code maintains the original functionality while improving readability and removing unnecessary comments. The image remains in its original location and format. The code examples are now presented more concisely within the comments, focusing on the core logic of each conditional statement type.

The above is the detailed content of Examples for condition statement,if,if else,else if. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template