Arrays
Arrays
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Note – slight change from original notes
17
18
19
20
Java has well-defined rules for specifying the order in which the operators in an
expression are evaluated when the expression has several operators. For example,
multiplication and division have a higher precedence than addition and subtraction.
Precedence rules can be overridden by explicit parentheses.
Precedence Order.
When two operators share an operand the operator with the higher precedence goes
first. For example, 1 + 2 * 3 is treated as 1 + (2 * 3), whereas 1 * 2 + 3 is treated as (1
* 2) + 3 since multiplication has a higher precedence than addition.
21
22
public static void main(String[] args) {
int[] feetSize;
int total, average;
total =0;
average =0;
23
24
25
26
27
28