title: Java - is adding a key/value to a map within a map in 1 line of code possible?
body: <p>I have HashMap 1, which contains 5 keys, all of which have Hashmaps as values. I want to add key/value pairs to these sub-Maps.</p>
  
  <pre><code>map1.get(subCategoryMap).put(newKey, newValue); 
  </code></pre>
  
  <p>My thinking is:</p>
  
  <pre><code>map1.get(subCategoryMap);
  </code></pre>
  
  <p>returns another map. I could split this line into two lines and have:</p>
  
  <pre><code>map2 = map1.get(subCategoryMap);
  map2.put(newKey, newValue);
  </code></pre>
  
  <p>But I would MUCH prefer to do it in one step. Which is why I am trying </p>
  
  <pre><code>map1.get(subCategoryMap).put(newKey, newValue); 
  </code></pre>
  
  <p>This doesn't work (doesn't like .put() on an object). Is it possible to access the sub-Map and add to it in the same line of code like I am above, or do I need to split this into 2 lines?</p>