title: what is the fastest substring search method in Java
body: <p>I need to implement a way to search substring (needles) in a list of string (haystack) using Java.</p>
  
  <p>More specifically, my app has a list of user profiles. If I type some letters, for example, "Ja", and then search, then all the users whose name contains "ja" should show up. For instance, the result could be "Jack", "Jackson", "Jason", "Dijafu".</p>
  
  <p>In Java, as I know, there are 3 build-in method to see search substring in a string.</p>
  
  <ol>
  <li><p>string.contains()</p></li>
  <li><p>string.indexOf()</p></li>
  <li><p>regular expression. it is something like string.matches("ja")) </p></li>
  </ol>
  
  <p><strong>My question is:</strong>  What are the runtimes of each method above? which one is the fastest or most efficient or most popular way to check if the list of string contains a given substring.</p>
  
  <p>I know there exists some algorithms that do the same thing, such as Boyer–Moore string search algorithm, Knuth–Morris–Pratt algorithm and so on. I do not want to use them because I just have a small list of strings, and I think using them is kind of overkill for me right now. Also I have to type a lot of extra coding for such a non-build-in algorithm. 
  If you think my thoughts is not correct, please feel free to correct me. </p>