Home > Java > javaTutorial > if else else if

if else else if

DDD
Release: 2025-01-30 04:05:08
Original
941 people have browsed it
<code class="language-java">package Javaifelse;

public class Third {

    public static void main(String[] args) {
        int a = 10;
        int b = 59;
        int c = 120;
        if (a > b) {
            System.out.println("value a > b");
        } else if (b < c) {
            System.out.println("value b < c");
        } else {
            System.out.println("No condition met");
        }
    }
}</code>
Copy after login

if else else if

The original code had a syntax error. The corrected code above uses else if correctly to chain conditional statements. If a > b is false, then the program checks if b < c. If both are false, the else block executes. The output will be "value b < c".

The above is the detailed content of 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template