title: Alternative to double brace initialization
body: <p>I have a nested collection in the form:</p>
  
  <pre><code>HashMap&lt;String, HashMap&lt;String, List&lt;String&gt;&gt;&gt; errorList;
  </code></pre>
  
  <p>Now I initialize it inline using double braces like this</p>
  
  <pre><code>errorList.put(tempName, new HashMap&lt;String, List&lt;String&gt;&gt;() {{
      put("upl", new ArrayList&lt;String&gt;() {{ add("Y"); add("Upload Success"); }});
  }});
  </code></pre>
  
  <p>This lies in a foreach loop with the value of <code>tempName</code> changing in every iteration. 
  I did this because i couldn't use instances of <code>List&lt;String&gt;</code> or <code>HashMap&lt;String,List&lt;String&gt;&gt;</code> because every time i changed the value in that instance it is reflected in the collection it is nested in. So i am forced to create new instances with double brace initialization.</p>
  
  <p>Thing is: I want to use a list object. Instead of </p>
  
  <pre><code>new ArrayList&lt;String&gt;() {{ add("Y"); add("Upload Success"); }}
  </code></pre>
  
  <p>I want to use a variable.</p>
  
  <p>How can I do this?</p>