June 2017
Beginner
1296 pages
69h 23m
English
... 7 public static void main(String[] args)
8 {
9 Singleton firstSingleton;
10 Singleton secondSingleton;
11
12 // create Singleton objects
13 firstSingleton = Singleton.getInstance();
14 secondSingleton = Singleton.getInstance();
15
16 // the "two" Singletons should refer to same Singleton
17 if (firstSingleton == secondSingleton)
18 System.err.println("firstSingleton and secondSingleton " +
19 "refer to the same Singleton object");
20 } // end main
21 } // end class SingletonTest

Structural design patterns describe common ways to organize classes and objects in a system. The Gang-of-Four ...
Read now
Unlock full access