Slide 13
Slide 13 text
jgs
00010000
Singleton
class Main {
public static void main(String []a){
// Constructor is protected -- cannot use new
Singleton s1 = Singleton.getInstance();
Singleton s2 = Singleton.getInstance();
// Test for same instance
if (s1 == s2){
// true - Objects are the same instance
}
}
}