title: Map of maps - putting value to inner map
body: <p>I have map of maps</p>
  
  <pre><code>Map&lt;String, Map&lt;String,Integer&gt;&gt; outerMap = new HashMap&lt;String, Map&lt;String, Integer&gt;&gt;();
  </code></pre>
  
  <p>and I want to put some values to inner map. Is that correct way? Or it can be done better?</p>
  
  <pre><code>class SampleMap {
      Map&lt;String, Map&lt;String, Integer&gt;&gt; outerMap = new HashMap&lt;String, Map&lt;String, Integer&gt;&gt;();
  
      public void add(String outerKey, String innerKey, Integer value) {
          Map&lt;String, Integer&gt; tempMap = new HashMap&lt;String, Integer&gt;();
          if (outerMap.size() &gt; 0)
              tempMap = outerMap.get(outerKey);
          tempMap.put(innerKey, value);
          outerMap.put(key, tempMap);
      }
  }
  </code></pre>