I just came across a piece of code I find interesting (because I have never seen it as a question before in 2 years of programming)
int x = 5;
int y = 3;
int z = y + (y+=1) % 4 + (x-=2) / 3;
System.out.println(z);
The output is 4.
I am wondering why is the left most 'y' evaluated first instead of the '(y+=1)' which would then resulted in an output of 5. (in other words, why is the bracket not forcing the order of precedence?)
I am not sure what to search since searching 'java order of precedence' returns results that at best shows tricky examples of y++, ++y kind of questions or just the order of precedence table.
I tagged Java but I have tested this with C# and javascript so it is probably a general thing in programming.
Update
I was mistaken about the order of precedence and order of evaluation.
This article helped me to further understand the answers provided.