5/11 - Can someone break down what's happening in the code for me?


#1


I'm able to do the exercise, I just want to be sure that I understand what is going on.

The way I see it, on the first pass, the expression in the parentheses (5 < 2 && 3 < 5) evaluates to false.
On the second pass inside the parentheses the expression (1 < 8 || false) evaluates to true.
On the third pass it evaluates to !(true) - meaning false.

Is my understanding of it correct?


public class Precedence {
    public static void main(String[] args) {

        boolean riddle = !( 1 < 8 || (5 > 2 && 3 < 5));
        System.out.println(riddle);

    }
}


#2

I would say you have it down to the T! Great job! And as always if you want to check this yourself the lesson you are on in 5.) Boolean Operators: Precedence and the previous lessons cover all this very well and you can compare past concepts to this lesson now to check to see if your understanding is correct.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.