单例模式的静态内部类,get方法为什么要final
public class Singleton {
// 静态内部类在 JVM 中是唯一的
private static class SingletonHoder {
private static final Singleton INSTANCE = new Singleton();
}
private Singleton() {
// 构造
}
private static final Singleton getInstance() {
return SingletonHoder.INSTANCE;
}
}