Skip to content

Commit 406d2e7

Browse files
committed
simplified the println
1 parent 13abf49 commit 406d2e7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

singleton/src/main/java/com/iluwatar/App.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static void main(String[] args) {
2424

2525
EnumIvoryTower enumIvoryTower1 = EnumIvoryTower.getInstance();
2626
EnumIvoryTower enumIvoryTower2 = EnumIvoryTower.getInstance();
27-
System.out.println("enumIvoryTower1=" + enumIvoryTower1.getDeclaringClass().getCanonicalName() + "@" + enumIvoryTower1.hashCode());
28-
System.out.println("enumIvoryTower2=" + enumIvoryTower2.getDeclaringClass().getCanonicalName() + "@" + enumIvoryTower2.hashCode());
27+
System.out.println("enumIvoryTower1=" + enumIvoryTower1);
28+
System.out.println("enumIvoryTower2=" + enumIvoryTower2);
2929
}
3030
}

singleton/src/main/java/com/iluwatar/EnumIvoryTower.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@ public enum EnumIvoryTower {
1111
public static EnumIvoryTower getInstance() {
1212
return INSTANCE;
1313
}
14+
15+
@Override
16+
public String toString() {
17+
return getDeclaringClass().getCanonicalName() + "@" + hashCode();
18+
}
1419
}

0 commit comments

Comments
 (0)