title: Using super() for equals() in a subclass in a different package
body: <p>I have a class Vehicle which is in package A and a class Car which is in package B and I want to use equals method and take advantage of inheritance by using super(), but I don't know how to do this.     </p>
  
  <p>When I try to run the file in main I get this:</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
      at vehicle.Vehicle.equals(Vehicle.java:97)
      at car.Car.equals(Car.java:104)
      at Main.main(Main.java:48)
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>public boolean equals(Vehicle other) {
      if (this.type.equals(other.type)) {
          if (this.year == other.year &amp;&amp; this.price == other.price) {
              return true;
          } else {
              return false;
          }
      } else {
          return false;
      }
  }
  //equals in Car
  public boolean equals(Car other) {
      if (this.type.equals(other.type)) {
          if (this.speed == other.speed &amp;&amp; this.door == other.door) {
              if (super.equals(other)) {
                  return true;
              } else {
                  return false;
              }
          } else {
              return false;
          }
      } else {
          return false;
      }
  }
  </code></pre>