title: Quick comparison strings with startsWith
body: <p>I have the following code:</p>
  
  <pre><code>String[] names = {"aa", ..........., "bb"};
  for (int i = 0; i &lt; names.length; i++) {
      if (names[i].toLowerCase().startsWith(query.toLowerCase()))
          c.addRow(new Object[]{i, names[i]});
  }
  </code></pre>
  
  <p>Since the array names can be long, I'm wondering what is the best way to write this code from performance point of view. In this way the loop is O(N). Is there any java data structure to do the same thing in a quicker way?</p>