Data and Expressions: Java Software Solutions
Data and Expressions: Java Software Solutions
Data and Expressions: Java Software Solutions
John Lewis
William Loftus
object method
information provided to the method
name
(parameters)
• See Countdown.java
X: 25
Y: 65
Z: 30050
• See Roses.java
int total;
int count, temp, result;
• Example declarations:
char topGrade = 'A';
char terminator = ';', separator = ' ';
a + b + c + d + e a + b * c - d / e
a / (b + c) - d % e
a / (b * (c + (d - e)))
a + b + c + d + e a + b * c - d / e
1 2 3 4 3 1 4 2
a / (b + c) - d % e
2 1 4 3
a / (b * (c + (d - e)))
4 3 2 1
+
a + (b – c) / d
a /
- d
b c
count = count + 1;
• or prefix form:
++count
is equivalent to
num = num + count;
+= x += y x = x + y
-= x -= y x = x - y
*= x *= y x = x * y
/= x /= y x = x / y
%= x %= y x = x % y
is equivalent to
result = result / ((total-MIN) % num);