Help Asap! 5.Boolean Operators : Precedence


#1
	// ( !true || (false && true) )
	boolean puzzle = true;
	System.out.println(puzzle);

Set the boolean variable puzzle equal to the Boolean result of the single line comment directly above it.


#2

You only have two options there, and the one you tried didn't work. :smile:


#3

:unamused: gee thanks for the help.


#4

I can give you a walkthrough on how to get from that ugly equation to true if you'd like -- I didn't mean to be so short.


#6

please do,i would really appreciate it. :blush:


#7

Here is the precedence order for evaluating boolean expressions:

  • brackets
  • !
  • &&
  • ||

We are starting off with

!true || (false && true)

Brackets have the highest precedence so we evaluate those first. The && operator returns true only when both sides are true. That leaves us with:

!true || false

! has the next highest precedence. The ! operator returns the opposite. That leaves us with:

false || false

The || operator returns true when at least one side is true. That leaves us with:

false