我有一个单身课程
public class Singleton {
static Singleton instance;
public static Singleton getInstance()
{
if (instance == null)
{
instance = new Singleton();
}
return instance;
}
考虑一个公共函数method()在类Singleton中定义。
这是在单例类中调用方法的最佳方式:
辛格尔顿。method() - 静态调用方法
或者
Singleton.getInstance.method() - 方法不是静态的?