Rameen Shahzad

Assignment 1
09814
Singleton Class

package singleton;
public class Single_class {
private Single_class () {}
private static Single_class instance;
public static Single_class getInstance () {
if(instance == null){
instance = new Single_class();}
return instance; }
}

package singleton;
public class Demo {
public static void main(String[] args) {
Single_class a1 = Single_class.getInstance();
Single_class a2 = Single_class.getInstance();
}
}

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.