exercise 11 has been bugging how i should write the code.

Hi. Can you post the code you have attempted with?

boolean tricky = !( 3 >= 3 && (true || true) );

System.out.println(tricky);

Use the precedence rules to help you evaluate the Boolean expression in the single line comment above the tricky variable.

Then, set the boolean variable tricky equal to the result (either true or false).

First, you don’t actually have to do anything to the comment you are just evaluating it with the statement you will code below it. So you can put the ( 3 >= 3 && (true || true) ) back behind //
Secondly, All you have to do is do exactly what the instructions say set boolean var tricky equal to either true or false. So this might look like this:

``````boolean tricky = false;
``````

If you need help on the rest of the lesson then just ask away! And of course if that doesn’t help then shout back lol

1 Like

Thanks, I’m getting the hang of this now

1 Like

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

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

}
``````

}
but how this is possoble

(1<8= As 1 is less than 8 it will print as True)
(5>2 =As 5 is less than 8 it will print as True)
(3<5 =As 3 is less than 8 it will print as True)

So we have now

!(True || (true && true))

Which will become now as

!(True || True)

Which will become now as
!(True)

Nd will print as False…

No it’s not.It showing false.

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