title: Fast Lookup of Java
body: <p>I currently have a String array that I need to search many times for an exact match. What would be the best data structure to use?</p>
  
  <pre><code>Example - String array with elements
  
  cat
  dog
  squirrel
  raccoon
  aardvark
  </code></pre>
  
  <p>The java code receives searches for strings and iterates over the array:</p>
  
  <ol>
  <li>Query for 'dogg' - returns nothing</li>
  <li>Query for 'raccoon' - returns raccoon</li>
  </ol>
  
  <p>My current code does the following:</p>
  
  <pre><code>for (String element : myList) {
        if (element.equals(searchTerm)) {
              return searchTerm;
        }
  }
  </code></pre>
  
  <p>Is there a more efficient way to do this search? I thought about using a Map, but I couldn't think of a good value (the key would be the 'dog'/'cat'/etc....). Should I use the same value for the key and the value? Is there a better data structure to use?</p>