java静态内部类的加载顺序:https://www.cnblogs.com/maohuidong/p/7843807.html
内部类静态单例模式:https://blog.csdn.net/a303549861/article/details/53028349
public class Singleton {
private Singleton(){
}
private static class SingletonHolder{
private final static Singleton instance=new Singleton();
}
public static Singleton getInstance(){
return SingletonHolder.instance;
}
}
静态内部类在使用时才加载, 因此保证了lazy loading.
网友评论