+ 2
Singleton object in java
3 Réponses
+ 4
A Singleton typically has a private constructor and the single instance can be retrieved via static method. For example:
public class God {
private static God instance = new God();
private God() {
}
public static God getInstance() {
return instance;
}
}
Excuse me if you think that God is not a singleton or doesn't exist at all. :)
0
and where is a question?
0
What is Singleton object and when it is used?