+ 2

Singleton object in java

12th Mar 2017, 6:02 PM
Arun A
Arun A - avatar
3 Respostas
+ 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. :)
12th Mar 2017, 7:51 PM
Tamás Barta
Tamás Barta - avatar
0
and where is a question?
12th Mar 2017, 6:22 PM
Ihor
0
What is Singleton object and when it is used?
12th Mar 2017, 6:31 PM
Arun A
Arun A - avatar