title: Storing a HashMap inside another HashMap and improving performance
body: <p>I am supposed to created a <code>HashMap</code> inside another <code>HashMap</code> as shown below which can store the value inside the inner <code>HashMap</code> based on the key of the outer <code>HashMap</code> at the runtime</p>
  
  <p>i.e. required output for program should be of the format </p>
  
  <pre><code>   { 1 = {11 = "aaa",15 = "bbb"}, 2 = {13 = "ccc", 14 = "ddd"} }
  </code></pre>
  
  <p>where 1,2 are Key values for Outer HashMap. </p>
  
  <p>Below is the Code provided for it Is there any better approach to improve performance</p>
  
  <pre><code>HashMap&lt;Integer, HashMap&lt;Integer, String&gt;&gt;Outer 
                     = new HashMap&lt;Integer, HashMap&lt;Integer,String&gt;&gt;();
  
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      int count = Integer.parseInt(br.readLine());
      for(int i =0;i&lt;count;i++)
      {
          String input[] = br.readLine().split("\\s");
  
          //HashMap&lt;Integer,String&gt;inner = new HashMap&lt;Integer, String&gt;();
          int key = Integer.parseInt(input[0]);
          if(Outer.isEmpty() || !Outer.containsKey(key))
          {
              HashMap&lt;Integer, String&gt; inner = new HashMap&lt;Integer, String&gt;();
              inner.put(Integer.parseInt(input[1]),input[2]);
              Outer.put(key, inner);
          }
          else if(Outer.containsKey(key))
              {
                  HashMap&lt;Integer, String&gt; inner = (HashMap&lt;Integer, String&gt;) Outer.get(key).clone();
                  inner.put(Integer.parseInt(input[1]), input[2]);
                  Outer.put(key, inner);
              }
      }
  </code></pre>