Boolean predence! i do not understand clearly, please help


I did not really understand clearly how boolean precedence works, could someone please help.
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) );



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! :smiley: And of course if that doesn't help then shout back lol


Thanks, I'm getting the hang of this now


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

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


Answer is false
but how this is possoble


So lets start with like this

(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

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.