title: String indexed collection in Java
body: <p>Using Java, assuming v1.6.</p>
  
  <p>I have a collection where the unique index is a string and the non-unique value is an int.
  I need to perform thousands of lookups against this collection as fast as possible.</p>
  
  <p>I currently am using a <code>HashMap&lt;String, Integer&gt;</code> but I am worried that the boxing/unboxing of the Integer to int is making this slower.</p>
  
  <p>I had thought of using an <code>ArrayList&lt;String&gt;</code> coupled with an <code>int[]</code>.</p>
  
  <p>i.e. Instead of:</p>
  
  <pre><code>int value = (int) HashMap&lt;String, Integer&gt;.get("key");
  </code></pre>
  
  <p>I could do </p>
  
  <pre><code>int value = int[ArrayList&lt;String&gt;.indexOf("key")];
  </code></pre>
  
  <p>Any thoughts? Is there a faster way to do this?</p>
  
  <p>p.s. I will only build the collection once and maybe modify it once but each time I will know the size so I can use <code>String[]</code> instead of <code>ArrayList</code> but not sure there's a faster way to replicate indexOf...</p>