title: Compare the ArrayList values and HashMap values
body: <p>I have a small query with respect to the comparison of ArrayList value with the HashMap value and extract the key value if they are equal. I am reading two files and storing them in ArrayList and HashMap respectively. I have to compare these values and extract the key from HashMap.</p>
  
  <p>For example:</p>
  
  <pre><code>ArrayList&lt;String&gt; list=new ArrayList&lt;String&gt;();
  list.add("A");
  list.add("B");  
  list.add("C");  
  list.add("D");  
  Iterator itr=list.iterator();  
  while(itr.hasNext()){  
      System.out.println(itr.next());  
  }
  
  HashMap&lt;String,String&gt; hm=new HashMap&lt;String,String&gt;();  
  hm.put("Key A","A");  
  hm.put("Key B","B");  
  hm.put("Key C","C");  
  hm.put("Key D","D");  
  for(Map.Entry m : hm.entrySet()){  
      System.out.println(m.getKey() + " " + m.getValue());  
  }
  </code></pre>
  
  <p>I have to compare the ArrayList and HashMap and if both of them contains the value "A" then Key A should be returned.</p>