-3
如果我写在java中的私人构造函数比它的默认构造函数的作品?在课堂上使用私有构造函数是什么?是一个私有构造函数的默认构造函数,它的用途是什么?
public class BillPughSingleton {
private BillPughSingleton() {
}
private static class LazyHolder {
private static final BillPughSingleton INSTANCE = new BillPughSingleton();
}
public static BillPughSingleton getInstance() {
return LazyHolder.INSTANCE;
}
}
也解释这段代码是如何工作的,什么是价值回归
它只提供BillPughSingleton类的一个实例。这是Singleton设计模式。 – Viraj