title: Unable to get values from a hashmap which uses a arraylist as value is cleared
body: <p>I am working on a piece of code which has a Hashmap. This hashmap has a string as key and an arraylist as value. I populate the arraylist and then put the value into the hashmap. After putting the value, I want to clear the arraylist so that no old values are present.</p>
  
  <p>Please see below code:</p>
  
  <pre><code>ArrayList&lt;Bean&gt; elements = new ArrayList&lt;Bean&gt;();
  
          for(int j=0; j&lt;array.length; j++){
              String[] id = {"2439","70212","9021","0104","0255","10353","3889","8990","10277"};
              String[] Title = {"Gulliver","Good=Guys","Gnomeo","Gene","ABCD","High","Green=Lantern","Gnomeo2","WXYZ"};
              for(int i=0; i&lt;id.length; i++){
                  Bean bean = new bean();
                  bean.ID(id[i]);
                  bean.Title(title[i]);
                  elements.add(bean);
              }
              udbResults.put(array[j], elements);
              elements.clear();
          }
  </code></pre>
  
  <p>Now when i try to print the values from the hashmap, i am not getting any content. This maybe because of the arraylist.clear(). Why does this happen?</p>
  
  <p>Also I didnt want to create new arraylist for each data hence i wanted to remvoe the contents but its not working.</p>
  
  <p>Any way to go about this.</p>
  
  <p>Thanks,</p>
  
  <p>swati</p>