2008年6月14日星期六

staticMethodSingleton-lazyInitiation

// lazy initiation
final class Singleton{private static Singleton SINGLETON=null;private Singleton(){//prevent initiation outside}//:fpublic static Singleton(){
if (SINGLETON==null){
SINGLETON=new Singleton();
}return SINGLETON;}//:fpublic Singleton clone(){throw new CloneNotSupportedException();}//:f}//:c

没有评论: