Cannot figure out the riddle lesson

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/learn-java/lessons/conditionals-control-flow/exercises/boolean-operators-precedence?action=resume (5. Boolean Operators: Precedence)

<In what way does your code behave incorrectly? Include ALL error messages.>
The only error I get is to the right and the black box on the right reports false. “Almost! Did you use each Boolean operator no more than one time?”

```

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

    boolean riddle = ! (false || (true && false));
    System.out.println(false);

}

}

<do not remove the three backticks above>

We are given an incomplete expression to finish by replacing the /**/ in,

boolean riddle = /**/ ( 1 < 8 /**/ (5 > 2 /**/ 3 < 5));

We have three operators, !, && and || and we can only use each once. Start by evaluating the operand expressions.

1 < 8  => true
5 > 2  => true
3 < 5  => true

We are asked to return a false from our completed expression. It would appear all we need to do is make the expression true and then NOT it to result in false.

( true /**/ ( true /**/ true ))

Both of the following will yield true

( true || ( true && true ))

( true && ( true || true ))

So,

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

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