Greenhorn

Posts: 14

posted 3 years ago

What exactly is your question?

You can find a table that shows the precedence of operators in Oracle's Java Tutorials: Operators. As you can see in the table, % has the same precedence as multiplication * and division /. Expressions are evaluated from left to right, so if you have an expression with multiple operators that have the same precedence, then the one on the left will be evaluated first.

So a line such as: int1 % int2 * (int3 + int1) / int2

will be interpreted as: ((int1 % int2) * (int 3 + int1)) / int2

Note that you didn't tell us what the values of the variables int1, int2, int3 is so we can't explain you with those values what exactly happens.

You can find a table that shows the precedence of operators in Oracle's Java Tutorials: Operators. As you can see in the table, % has the same precedence as multiplication * and division /. Expressions are evaluated from left to right, so if you have an expression with multiple operators that have the same precedence, then the one on the left will be evaluated first.

So a line such as: int1 % int2 * (int3 + int1) / int2

will be interpreted as: ((int1 % int2) * (int 3 + int1)) / int2

Note that you didn't tell us what the values of the variables int1, int2, int3 is so we can't explain you with those values what exactly happens.

Greenhorn

Posts: 14

posted 3 years ago

Thanks, I sorted out the problem,

values are int1=10, int2=20, int3=30

values are int1=10, int2=20, int3=30

Jesper de Jong wrote:What exactly is your question?

You can find a table that shows the precedence of operators in Oracle's Java Tutorials: Operators. As you can see in the table, % has the same precedence as multiplication * and division /. Expressions are evaluated from left to right, so if you have an expression with multiple operators that have the same precedence, then the one on the left will be evaluated first.

So a line such as: int1 % int2 * (int3 + int1) / int2

will be interpreted as: ((int1 % int2) * (int 3 + int1)) / int2

Note that you didn't tell us what the values of the variables int1, int2, int3 is so we can't explain you with those values what exactly happens.