我有一个像这样的Singleton类:
class Singleton {
static class SingletonHolder {
static final Singleton INSTANCE = new Singleton();
}
public static Singleton getInstance() {
return SingletonHolder.INSTANCE;
}
}
Run Code Online (Sandbox Code Playgroud)
我可以从其他班级这样打电话:
Singleton dummy = new Singleton();
Run Code Online (Sandbox Code Playgroud)
如果是,我怎么能禁用它?如果没有,那为什么我不能?