title: Iterator VS HashMap<String, Object> in JAVA
body: <p>Lets say that we have a collection of items. Which of the two is faster?</p>
  
  <pre><code>HashMap&lt;String, ObjectFoo&gt; hashmap = new HashMap&lt;String, ObjectFoo&gt;();
  /* .... add elements .... */
  ObjectFoo theElement = hashmap.get("nameOfObject");
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>ArrayList&lt;ObjectFoo&gt; arraylist = new ArrayList&lt;Object&gt;();
  /* .... add elements .... */
  Iterator&lt;ObjectFoo&gt; itFoo = arraylist.iterator();
  ObjectFoo obj;
  while(itFoo.hasNext()) {
    obj = itFoo.next();
    if (obj.name.equals("nameOfObject")) return obj;
  }
  </code></pre>
  
  <p>Suppose that:</p>
  
  <pre><code>public class ObjectFoo {
    public String name;
  }
  </code></pre>