单例模式:
public class Single {
private static final Single single = new Single();
private Single(){
}
public static Single sharedSingle(){
return single;
}
public void doSomething(){
System.out.println("TODO:");
}
/**
* @param args
*/
public static void main(String[] args) {
Single.sharedSingle();
// TODO Auto-generated method stub
Single.sharedSingle().doSomething();
}
}
网友评论