Skip to content

Commit d05bf3c

Browse files
authored
Refactor IncrementOperator class main method
Refactor IncrementOperator class to use IO for output and simplify main method.
1 parent a0e9223 commit d05bf3c

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

pitfalls/IncrementOperator.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
package com.zetcode;
2-
31
// there is a subtle difference between the
42
// prefix and suffix increment operators
53

6-
public class IncrementOperator {
7-
8-
public static void main(String[] args) {
4+
void main() {
95

10-
int num = 0;
6+
int num = 0;
117

12-
num = num++;
8+
num = num++;
139

14-
System.out.println(num);
10+
IO.println(num);
1511

16-
num = ++num;
17-
18-
System.out.println(num);
19-
}
12+
num = ++num;
13+
14+
IO.println(num);
2015
}

0 commit comments

Comments
 (0)