@@ -43,27 +43,24 @@ Pattern Singleton: One Class, one Instance.
43
43
Singleton is one of the Gangs of Four Design patterns and comes in the Creational Design Pattern category.
44
44
There are many implementations of this pattern, but we will implement the Thread Safe one.
45
45
Classes are in the package ` com.Singleton ` ;
46
+ ``` java
47
+ import com.singleton.SingletonThreadSafe ;
46
48
47
- ```java
48
- import com.singleton.SingletonThreadSafe;
49
-
50
- public class SingletonTest {
51
- public static void main(String[] args){
52
-
53
- SingletonThreadSafe sing = SingletonThreadSafe.getInstance();
54
- System.out.println(sing);
49
+ public class SingletonTest {
50
+ public static void main (String [] args ){
51
+ SingletonThreadSafe sing = SingletonThreadSafe . getInstance();
52
+ System . out. println(sing);
55
53
56
- // Now let's instanciate another class
54
+ // Now let's instanciate another class
57
55
58
- SingletonThreadSafe sing1 = SingletonThreadSafe.getInstance();
56
+ SingletonThreadSafe sing1 = SingletonThreadSafe . getInstance();
59
57
60
- System.out.println(sing1);
58
+ System . out. println(sing1);
61
59
62
- //Now check out your console.... What the hell, the two instances have the same reference :o
60
+ // Now check out your console.... What the hell, the two instances have the same reference :o
63
61
}
64
62
}
65
63
```
66
-
67
64
# Pattern Factory
68
65
69
66
Factory Pattern is one of the Creational Design pattern and it's widely used in JDK as well as frameworks like
0 commit comments