Files
  • Main.java
  • SingletonV1.java
  • SingletonV2.java
  • SingletonV3.java
  • SingletonV4.java
  • SingletonV5.java
  • SingletonV6.java
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class Main {
  public static void main(String[] args) {
    
    SingletonV1 singletonv1 = SingletonV1.getInstance();
    
    singletonv1.doSomething();
    
    
    SingletonV2 singletonV2 = SingletonV2.getInstance();
    
    singletonV2.doSomething();
    
    
    SingletonV3 singletonV3 = SingletonV3.getInstance();
    
    singletonV3.doSomething();
    
    
    SingletonV4 singletonV4 = SingletonV4.getInstance();
    
    singletonV4.doSomething();
    
    
    SingletonV5 singletonV5 = SingletonV5.getInstance();
    
    singletonV5.doSomething();
    
    
    SingletonV6 singletonV6 = SingletonV6.getInstance();
    
    singletonV6.doSomething();
  }
}
java version "1.8.0_31" Java(TM) SE Runtime Environment (build 1.8.0_31-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)