title: Trying to make an array of car objects, getting null
body: <p>My program allows the user to change the make of the car.  I want to make an array of 2 cars.  I declare an array using <code>Car[] driving = new Car[2]</code>.  Then in the constructor make their objects <code>driving[0] = new Car()</code> and <code>driving[1] = new Car()</code>.  I am not sure if this is the proper way of doing this since running my program gives me a NullPointerException.</p>
  
  <p>Driver class:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Driver
  {
      static Scanner sc = new Scanner(System.in);
      static int choice;
      static Car[] driving = new Car[2];
      public Driver(){
          driving[0] = new Car();
          driving[1] = new Car();
      }
      public static void main(String args[]){
              changeSettings();
          }
      static public void changeSettings(){
  
          System.out.println("Enter the make");
          driving[0].setMake(sc.nextLine());
          System.out.println("Done.");
      }
  }
  </code></pre>
  
  <p>Car class:</p>
  
  <pre><code>public class Car
  {
      private String make;
  
      public Car(){
          make = "Mercedes";
      }
  
      public String getMake(){
          return make;
      }
  
      public void setMake(String make){
          this.make = make;
      } 
  }
  </code></pre>
  
  <p>Error message: </p>
  
  <pre><code>java.lang.NullPointerException
  at Driver.changeSettings(Driver.java:23)
  at Driver.main(Driver.java:18)
  </code></pre>
  
  <p>It looks like the errors are at lines 18 and 23 but I can't think of a solution.  Is my way to making the car objects acceptable?</p>