if-else statement

Main.java
public class Main {
    public static void main(String[] args){
        boolean isRaining = true;
        if(isRaining) {
            System.out.println("You should take an umbrella!");
        } else {
            System.out.println("You don't need an umbrella!");
        }

    }
}

The boolean is a kind of primitive type. It has two values: true and false. You can use the boolean type to indicate true or false logic. The code snippets mean you should take an umbrella if it is raining.

Last updated