今天和一人讨论以下这几形式的单例,看这样写是否正确??
他说这样写不对。。晕了。。
public class Singleton
{
private static Singleton st;
public static Singleton getInstance()
{
if (null == st)
{
return new Singleton();
}
return st;
}
}
他说这样写不对。。晕了。。