title: How to check if a string contains an element of a string array?
body: <p>I'd like to to check if a string contains an element from a String array. I think that iterating all the array elements and seeing if String.contains(an element) does not seem to efficient. So I wonder if there's a more efficient way to make this look-up fast.</p>
  <p>For example, I want to get the country name from an address string. Users can write their address without any constraints. The address string can contain the country name or city name. So I want to see if the address string has an element from an array that I will build has a bunch of country names and city names.</p>
  <p>My current solution is:</p>
  <pre><code> ArrayList&lt;String&gt; list;
   String address;
              ...
      for (String s : list) {
          if (address.contains(s))
              return s;
      }
  </code></pre>
  <p>This is O(n). I wonder if there's a faster solution.</p>