public class SingleType
{
private static SingleType test = null;
private SingleType() {}
public static SingleType getInstance()
{
if(test == null)
test = new SingleType();
return test;
}
public void getName()
{
System.out.println("SingleType");
}
public static void main(String[] args)
{
System.out.println("obj1");
SingleType obj1 = SingleType.getInstance();
obj1.getName();
System.out.println("obj2");
SingleType obj2 = SingleType.getInstance();
obj2.getName();
System.out.println("obj3");
SingleType obj3 = SingleType.getInstance();
obj3.getName();
}
}