title: How to create HashMap dynamically
body: <p>I have <code>.txt</code> file with 5L values(Lines) in the following way and also have partition size <code>50000</code>.</p>
  
  <pre><code> 1
   3
  -1546.9
  -67.90
  3456
  .
  .
  .
  </code></pre>
  
  <p>With the following example you can understand what is mean by Partition in my point of view.</p>
  
  <p>after importing file data into list we can see in the following way.</p>
  
  <pre><code> importingdata={1,2,3,4,5,.........500000};
  </code></pre>
  
  <p>After partition, you can see in the following way.</p>
  
  <pre><code>PartitionList={{1,2,3,...50000},{50001,....,100000},{100001,......,150000},...{450000,.....500000}};
  </code></pre>
  
  <p>partitionList datatype is <code>ArrayList&lt;HashMap&lt;Integer,Double&gt;&gt;</code>.it means all sub-lists of partitionlist was <code>HashMap&lt;Integer,Double&gt;</code>.</p>
  
  <p>All <code>HashMap</code> lists starts their key values from <code>1 to 50000</code>.like in the following way.</p>
  
  <pre><code>     PartitionList={{1-&gt;1,2-&gt;2,3-&gt;3,...,50000-&gt;50000},{1-&gt;50001,.....,50000-&gt;100000},{1-&gt;100001,....,50000-&gt;150000},...,{1-&gt;450000,.....,50000-&gt;500000}};
  </code></pre>
  
  <p>I want to arrange file data in the above way while file importing time.</p>
  
  <p>for this I tried with sample code but it's not working.</p>
  
  <pre><code>public static void main(String[] args) {
      ArrayList&lt;HashMap&lt;Integer, Double&gt;&gt; finalList=new ArrayList&lt;&gt;();
      HashMap&lt;Integer, Double&gt; hash1=new HashMap&lt;&gt;();
      hash1.put(1, 1.0);
      hash1.put(2, 2.0);
      hash1.put(3, 3.0);
      finalList.add(hash1);
      System.out.println(finalList.size());
      System.out.println(hash1.size());
      hash1.clear();
      System.out.println(hash1.size());
      hash1.put(1, 1.0);
      hash1.put(2, 2.0);
      hash1.put(3, 3.0);
      finalList.add(hash1);
      System.out.println(finalList.size());
      System.out.println(hash1.size());
      hash1.clear();
      System.out.println(hash1.size());
      HashMap&lt;Integer, Double&gt; hash2=finalList.get(1);
      HashMap&lt;Integer, Double&gt; hash3=finalList.get(2);
      System.out.println(hash2.size());
      System.out.println(hash3.size());
  }
  </code></pre>
  
  <p>I hope,you guys understand what I am trying.
  Here I mention <code>5L</code> lines, but in my real case I am dealing with <code>80L</code> So suggest me with optimized code.</p>
  
  <p>Thanks</p>