RosettaCodeData/Task/Singleton/Java/singleton-3.java

21 lines
341 B
Java

class Singleton
{
private static Singleton myInstance;
public static Singleton getInstance()
{
if (myInstance == null)
{
myInstance = new Singleton();
}
return myInstance;
}
protected Singleton()
{
// Constructor code goes here.
}
// Any other methods
}