title: how to implement static list of objects in java
body: <p>just want to ask if the class i created below is correct or if something is wrong because of the use of static list of objects and if my implementation of encapsulation in correct because i need to limit the access to my static variable.</p>
  
  <pre><code>public class Car {
      private String carName, carPlateNumber;
      private static List&lt;Car&gt; carList;
  
      public Car(String carName, String carPlateNumber) {
          super();
          this.carName = carName;
          this.carPlateNumber = carPlateNumber;
      }
  
      public String getCarName() {
          return carName;
      }
  
      public void setCarName(String carName) {
          this.carName = carName;
      }
  
      public String getCarPlateNumber() {
          return carPlateNumber;
      }
  
      public void setCarPlateNumber(String carPlateNumber) {
          this.carPlateNumber = carPlateNumber;
      }
  
      public static void createCarList() {
          carList = new ArrayList&lt;Car&gt;();
      }
  
      public static void addCarToList(Car car) {
          carList.add(car);
      }
  
      public static Car getCarAt(int location) {
          return carList.get(location);
      }
  
      public static void clearCarList() {
          carList.clear();
      }
  
      public static List&lt;Car&gt; getCarList() {
           return carList;
      }
  }
  </code></pre>
  
  <p>and then to use this class like this</p>
  
  <pre><code>Car.createCarList();
  Car.addCarToList(new Car("Mustang","CA-12343"));
  . . .
  . . .
  </code></pre>
  
  <p>and so on....</p>