Consider the following example:
class Quirky {
public static void main(String[] args) {
int x = 1;
int y = 3;
System.out.println(x =
== is a comparison equality operator and it works from left to right.
x == (x = y);
here the old assigned value of x is compared with new assign value of x, (1==3)//false
(x = y) == x;
Whereas, here new assign value of x is compared with the new holding value of x assigned to it just before comparison, (3==3)//true
Now consider this
System.out.println((8 + (5 * 6)) * 9);
System.out.println(8 + (5 * 6) * 9);
System.out.println((8 + 5) * 6 * 9);
System.out.println((8 + (5) * 6) * 9);
System.out.println(8 + 5 * 6 * 9);
Output:
342
278
702
342
278
Thus, Parentheses plays its major role in arithmetic expressions only not in comparison expressions.