标签:ret 单例 blog bsp 单例设计 ati people logs null
1 class People{ 2 /** 3 * 恶汉单例设计模式 4 */ 5 private static People p=new People(); 6 private People(){ 7 } 8 public static People getPeople(){ 9 return p; 10 } 11 } 12 class Person{ 13 /** 14 * 懒汉单例设计模式 15 */ 16 private static Person p1; 17 private Person(){ 18 } 19 public static Person getPerson(){ 20 if (p1==null) { 21 p1=new Person(); 22 return p1; 23 } 24 return p1; 25 } 26 }
标签:ret 单例 blog bsp 单例设计 ati people logs null
原文地址:http://www.cnblogs.com/qq634571685/p/6652673.html