1、Person类里面
class Person
{
private static Person p;
public static Person GetSingle()
{
if (p ==
null)
{
p =
new Person();
}
return p;
}
private Person()
{ }
}
2、Program类里面
class Program
{
static void Main(
string[] args)
{
Person p =
Person.GetSingle();
}
}
转载于:https://www.cnblogs.com/ruanmou001/p/3446027.html
相关资源:JAVA上百实例源码以及开源项目
转载请注明原文地址: https://mac.8miu.com/read-78370.html