We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c94c8a3 commit 20b1c2bCopy full SHA for 20b1c2b
1 file changed
singleton/src/main/java/com/iluwatar/singleton/IvoryTower.java
@@ -27,22 +27,24 @@
27
*/
28
public final class IvoryTower {
29
30
- /**
31
- * Static to class instance of the class.
32
- */
33
- private static final IvoryTower INSTANCE = new IvoryTower();
34
-
35
/**
36
* Private constructor so nobody can instantiate the class.
37
38
private IvoryTower() {}
39
+ private static class IvoryTowerHolder {
+ /**
+ * Static to class instance of the class.
+ */
+ private static final IvoryTower INSTANCE = new IvoryTower();
40
+ }
41
+
42
43
* To be called by user to obtain instance of the class.
44
*
45
* @return instance of the singleton.
46
47
public static IvoryTower getInstance() {
- return INSTANCE;
48
+ return IvoryTowerHolder.INSTANCE;
49
}
50
0 commit comments