title: Call on different constructor with 'default' HashMap
body: <p>I had a lot of testcases running on the class MyClass, using it's default constructor: MyClass().</p>
  
  <p>Now the requirements of MyClass changed and the user can provide a HashMap to indicate some pairs . Now a MyClass needs to have at least one pair  and throws exceptions if one of those is null.</p>
  
  <p>I was hoping to create another default constructor to avoid having to rewrite all the test methods something like:</p>
  
  <pre><code>public MyClass() {
  
    HashMap&lt;KeyClass, ValueClass&gt; hashMap = HashMap&lt;KeyClass, ValueClass&gt;();
    hashMap.put(KeyClass.someValue, new ValueClass());
    this(hashMap);
  
  }
  </code></pre>
  
  <p>Now this doesn't work, because i have to call the other constructor first, so i thought of writing some method </p>
  
  <pre><code>private static HashMap&lt;KeyClass, ValueClass&gt; getDefaultHashmap();
  </code></pre>
  
  <p>and using it to call the other constructor like this:</p>
  
  <pre><code>public MyClass() {
  
    this(MyClass.getDefaultHashmap());
  
  }
  </code></pre>
  
  <p>But this seemed to me as not really good style, so i was hoping you could tell me what the right way to do something like this is!</p>