Middle
Jak programowo zabronić tworzenia obiektu tej klasy?
sobes.tech AI
Odpowiedź od AI
Uczynić konstruktor klasy prywatnym.
public class Singleton {
private Singleton() {
// Prywatny konstruktor
}
// ... reszta klasy
}
sobes.tech AI
Odpowiedź od AI
Uczynić konstruktor klasy prywatnym.
public class Singleton {
private Singleton() {
// Prywatny konstruktor
}
// ... reszta klasy
}