So, in this case it would return true when x is bigger than 4 and lower than 8, false otherwise.
William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Joined: Jan 25, 2010
So, it sounds like your saying (x > 4 && x < 8) is the same as ((x > 4) && (x < 8))?
Without parentheses it would seem to me if you evaluate left to right, you'd evaluate "x > 4", let's say true, then evaluate "true && x" where x is some int and you'd get a compiler error because an int does not resolve to a boolean. Where do I go haywire?
There's an order of precedence of operators in Java (and most other languages). Operators with higher precedence get applied first regardless of the order they appear - unless you use brackets to force a particular order.
For a possibly more familiar example, what would you expect (1 + 2*3) to be? The * has higher precedence than +, so it's 7, not 9.
Another example: = is actually an operator. If it wasn't for the rules of precedence, something as straightforward as x = a + 1 really wouldn't do what you'd expect (think about what the effect is if you applied that left-to-right).