title: Java subclass constructors not calling parent class constructor
body: <p>I ran into a weird situation the other day. Here it is:</p>
  
  <p>I had an abstract class and a child class extending it. The abstract class had a no parameter constructor to initialize a map, but that's it. </p>
  
  <p>The sub-class didn't have any constructors that I explicitly wrote, and everything worked fine.</p>
  
  <p>Then one day I added a custom constructor in the subclass with a bunch of parameters for a unit test. This broke my main program, however, because the map in its parent class was always null. </p>
  
  <p>To solve it, I put another constructor in the subclass that was totally blank (no params or anything). This for some reason assured that the super class constructor would be called and no null pointer exception thrown. Why was that not getting called before and why is it working now? </p>
  
  <p>Subclass:</p>
  
  <pre><code>public class BillToSite extends XWStoreRequestDataElement {
  private String country;
  private String state;
  private String county;
  private String city;
  private String zip;
  private String address;
  
  public BillToSite() { } //WHY DOES THIS FIX IT???
  
  //Only used for unit test. 
  public BillToSite(String address, String city, String state, String zip, String county, String country){
      this.address = address;
      this.city = city;
      this.state = state;
      this.zip = zip;
      this.county = county;
      this.country = country;
  }
  </code></pre>
  
  <p>Abstract class:</p>
  
  <pre><code>public abstract class XWStoreRequestDataElement {
  private Map&lt;String, String&gt; attributes;
  
  public XWStoreRequestDataElement(){
      attributes = new HashMap&lt;&gt;();
  }
  </code></pre>