We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 84efa30 commit cffe592Copy full SHA for cffe592
singleton/src/main/java/com/iluwatar/SingletonClass.java
@@ -0,0 +1,18 @@
1
+package com.iluwatar;
2
+
3
+public class SingletonClass {
4
5
+ private static SingletonClass singletonInstance = null;
6
7
+ public synchronized static SingletonClass getSingleton() {
8
+ /*
9
+ * The instance gets created only when it is called for first time.
10
+ * Lazy-loading
11
+ */
12
+ if (singletonInstance == null) {
13
+ singletonInstance = new SingletonClass();
14
+ }
15
16
+ return singletonInstance;
17
18
+}
0 commit comments