The following fragment of a Java program shows expressions with operators on integers:
int a, b, c; a = 10 / 3 + 10 % 3; b = 2 * -3 + 4; c = 2 * (a + b);
The following precedence rules between operators hold in Java (these are the same as those used in arithmetics):
Brackets can be used to change the way subexpressions have to be grouped. Note that in Java, only round brackets, ( and ), and not square or curly brackets, can be used to group subexpressions
Example: In Java, the expression a+b*-c is equivalent to a+(b*(-c))