16 class MainApp { 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 } } } Singleton
Winter 2023 Copyright. These slides can only be used as study material for the class CSC308 at Cal Poly. They cannot be distributed or used for another purpose.