Tabulate the precedence of
operators with its description and
priority.
Answers
Answered by
0
Now, take a look at the statement below:
int myInt = 12 - 4 * 2;
What will be the value of myInt? Will it be (12 - 4)*2, that is, 16? Or it will be 12 - (4 * 2), that is, 4?
When two operators share a common operand, 4 in this case, the operator with the highest precedence is operated first.
In Java, the precedence of * is higher than that of -. Hence, the multiplication is performed before subtraction, and the value of myInt will be 4.
Similar questions
Math,
3 months ago
Science,
3 months ago
Physics,
3 months ago
Computer Science,
6 months ago
India Languages,
6 months ago
Science,
1 year ago