5/11- why does this return "false"?


#1



https://www.codecademy.com/courses/learn-java/lessons/conditionals-control-flow/exercises/boolean-operators-precedence

The code does not behave incorrectly as per the excercise, but I'm at a loss as to how it prints "false". It seems to me that the first return ( for !( 1 < 8 ) would be "false", as 1 < 8 == true. Then, the && should return "true" since both values are true. Therefore, with the ||, I see true OR false, which should equate to "true", right?

I apologize; I am brand new to this. Thank you in advance.

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

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

	}
}


#2

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