Using boolean Data Type

Practise your skills and try to change the code. Read the comments and try what is within the TODO comment.

class BooleanDemo {
    public static void main (String[] args) {
        //boolean type hold the value of either true or false
        boolean loggedIn = true;
        System.out.println("loggedIn " + loggedIn);

        //when using boolean types, the convention is to use is before the variable name
        boolean isAuthenticated = false;
        System.out.println("isAuthenticated " + isAuthenticated);

        //boolean types are used in conditional statements
        //The double equals(==) checks for equality. We will cover the if statement later on
        if(isAuthenticated == true){
            System.out.println("I am auntenticated");
        }else {
            System.out.println("I am not auntenticated");
        }

        //TODO
        //Change the isAuthenticated to false 
        //And change the order of the expression in the if statement so that it outputs the right message
    }
}
  

results matching ""

    No results matching ""