单例

public class Singleton { 

 private static class Holder { // lazy class

  static final Singleton 

   instance = new Singleton();

 }

 public static Singleton getInstance() {

  return Holder.instance;   

 } 

} 

 

你可能感兴趣的:(单例)