单例设计模式和多例

 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 }

 

posted @ 2019-07-17 22:56  zzu_Lee  阅读(132)  评论(0编辑  收藏  举报