@@ -44,26 +44,26 @@ Pattern Singleton: One Class, one Instance.
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
46
47
- ```java
47
+ ``` java
48
+ import com.singleton.SingletonThreadSafe ;
48
49
49
- import com.singleton.SingletonThreadSafe;
50
+ public class SingletonTest {
51
+ public static void main (String [] args ){
50
52
51
- public class SingletonTest {
52
- public static void main(String[] args){
53
+ SingletonThreadSafe sing = SingletonThreadSafe . getInstance();
54
+ System . out . println(sing);
53
55
54
- SingletonThreadSafe sing = SingletonThreadSafe.getInstance();
55
- System.out.println(sing);
56
+ // Now let's instanciate another class
56
57
57
- // Now let's instanciate another class
58
+ SingletonThreadSafe sing1 = SingletonThreadSafe . getInstance();
58
59
59
- SingletonThreadSafe sing1 = SingletonThreadSafe.getInstance( );
60
+ System . out . println(sing1 );
60
61
61
- System.out.println(sing1);
62
-
63
- //Now check out your console.... What the hell, the two instances have the same reference :o
62
+ // Now check out your console.... What the hell, the two instances have the same reference :o
64
63
}
65
64
}
66
- ```
65
+ ```
66
+
67
67
# Pattern Factory
68
68
69
69
Factory Pattern is one of the Creational Design pattern and it's widely used in JDK as well as frameworks like
0 commit comments