我正在研究一个法典基础,我经常看到这样的情况:
public class SomeClass
{
protected static SomeClass myObject;
//...
public static SomeClass getObject()
{
return myOjbect
}
}
I d like to make sure I understand the purpose behind this. Is it to ensure one instance of the class gets shared even if it is instantiated multiple times? I am not sure about the vocabulary here, or else I d search for the answer, so if this pattern has a name, please let me know.
而且,这似乎只是鸡肉和鸡蛋的定义,因为该类含有该类的物体。 为什么这种说法实际上自相矛盾?
感谢!