File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
singleton/src/main/java/com/iluwatar Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -22,5 +22,9 @@ public static void main(String[] args) {
2222 System .out .println ("threadSafeIvoryTower1=" + threadSafeIvoryTower1 );
2323 System .out .println ("threadSafeIvoryTower2=" + threadSafeIvoryTower2 );
2424
25+ EnumIvoryTower enumIvoryTower1 = EnumIvoryTower .getInstance ();
26+ EnumIvoryTower enumIvoryTower2 = EnumIvoryTower .getInstance ();
27+ System .out .println ("enumIvoryTower1=" + enumIvoryTower1 .getDeclaringClass ().getCanonicalName () + "@" + enumIvoryTower1 .hashCode ());
28+ System .out .println ("enumIvoryTower2=" + enumIvoryTower2 .getDeclaringClass ().getCanonicalName () + "@" + enumIvoryTower2 .hashCode ());
2529 }
2630}
Original file line number Diff line number Diff line change 1+ package com .iluwatar ;
2+
3+ /**
4+ *
5+ * Enum Singleton class.
6+ *
7+ */
8+ public enum EnumIvoryTower {
9+ INSTANCE ;
10+
11+ public static EnumIvoryTower getInstance () {
12+ return INSTANCE ;
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments