I have a first class for which the constructor takes a parameter.
public class First {
First(Object o){
o.toString();
}
}
I have a second class that extends this first one.
public class Second extends First {
Second(Object o) {
super(o);
}
}
I want to keep the constructor of the Secondprivate class in order to be able to create an instance of only one instance of this class (for example, using the Singleton template), but the compiler does not allow me to do this.
If I cannot set the constructor as private here, what can I do to allow only one instance of the class to be created?
source
share