单例设计模式和多例

 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 }
相关文章
相关标签/搜索