class Singleton {
private static Singleton s = new Singleton();
protected Singleton() {
System.out.println("S");
}
public static Singleton getInstance() {
return s;
}
}
public class Test {
public void method() {
Singleton.getInstance();
}
public static void main(String [] str) {
new Test();
}
}
Login in to like
Login in to comment