title: Efficiency of String matching, Equals vs. Matches methods
body: <p>Say I have to compare some string objects in Java, and I have to do it like a million times for a high volume program.  The strings will either be completely identical or they should not count as a match.  Which method is more efficient to use, equals (object equality) or matches (regex)?  An example:</p>
  
  <pre><code>String a = "JACK", b = "JACK", c = "MEG";
  a.equals(b);//True
  a.equals(c);//False
  
  a.matches(b);//True
  a.matches(c);//False
  </code></pre>
  
  <p>Both methods give me the results I want, but I'd like to know which one would be more efficient given the high volume processing.</p>