Skip to content

Commit 53713ee

Browse files
authored
Refactor IntegerEqual class main method
Refactored main method and updated print statements to use IO class.
1 parent 1090cd2 commit 53713ee

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

pitfalls/IntegerEqual.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
package com.zetcode;
2-
31
// The == operator compares object references and equals()
42
// object values. Java internally caches integers
53
// from -128 to +127, so comparing them with == 'works'.
64
// we should use equals
75

8-
public class IntegerEqual {
9-
10-
public static void main(String[] args) {
6+
void main() {
117

12-
Integer a = 127;
13-
Integer b = 127;
14-
Integer c = 128;
15-
Integer d = 128;
8+
Integer a = 127;
9+
Integer b = 127;
10+
Integer c = 128;
11+
Integer d = 128;
1612

17-
System.out.println(a == b);
18-
System.out.println(c == d);
19-
}
13+
IO.println(a == b);
14+
IO.println(c == d);
2015
}
16+

0 commit comments

Comments
 (0)