1public class CounterDemo {
2
3 public static void main(String[] args) {
4
Counter tally = new Counter();
5 tally.click();
6 tally.click();
7 int result = tally.getValue();
8 System.out.print("result: ");
9 System.out.println(result);
10 }
11
12}
13
14
15public class Counter {
16
17 private int value;
18
19 public int getValue() {
20 return value;
21 }
22
23
24 public void click() {
25 value = value + 1;
26 }
27
28
29 public void reset() {
30 value = 0;
31 }
32}
Literals
Stack
Stack frame
Counter
getValue()
click()
reset()
System.out.println(text)
System.out.print(text)
+