Boolean Operators: Precedence Exercise


#1

I completed the exercise, and it prints out "false," but I'm confused about the order in which the code is evaluated. Can you tell me how to evaluate the code step by step? Thanks!

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

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

	}
}


#2

I can't even move forward even though it prints out false. So frustrating.

Here is my code:

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

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

}

}


#3

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

It works for me :slight_smile:

As you can see, you should invert the signs "and" and "or" and move the ")" following the "8" :slight_smile:

I hope this helps.


#4

How do you enter the ││ from a keyboard? I tried using the Alt 179 symbol twice but it returned an error. I don't see ││ on my keyboard.


#5

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