单例设计模式和多例

 1 public class Car {
 2     private static Car car = new Car();
 3     /**
 4      *  多例,getInstance()取出里面一个,(jdbc,连接池)
 5         private static List<Car> cars = new ArrayList<Car>();
 6      */
 7     private Car() {}
 8     public static Car getInstance() {
 9         return car;
10     }
11 }

猜你喜欢

转载自www.cnblogs.com/hengzhezou/p/11204279.html