Boolean Operators: Precedence

For the precedence lesson, i got the correct answer. I’m not too sure why i got the correct answer too. Shouldn’t my reading be true instead? However, I’m a little confused as to the precedence part. If ! is read first, followed by && then ||. Doesn’t that mean only the reading of || matter since its the last one to be read?

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

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


this is true, except anything in parentheses is evaluated first, even before !

so, given the or operator is between parentheses means it evaluates first.

1 Like

Oh I see. That was pretty simple. Haha. Thanks!

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