title: Checking equality of three or more Strings in Java
body: <p>I know this is a very basic question, but I am always trying to find ways to make my code a clean and concise as possible. Is there a way to compare the equality of three or more strings in a single <code>if()</code> statement? I am currently using the <code>&amp;&amp;</code> operator to progressively compare each string. However, as you could imagine, between long variable names and methods being called, these <code>if()</code> statements get very cluttered very quickly. Additionally I am planning to have an unknown number of these Strings, and would like to avoid complex <code>for</code> loops with cluttered <code>if()</code>s nested inside of them. This is what my code currently looks like:</p>
  
  <pre><code>String a = new String("a");
  String b = new String("b");
  String c = new String("c");
  if(a.equals(b) &amp;&amp; b.equals(c)) {
      doSomething();
  }
  </code></pre>
  
  <p>Is there a way, or a collection of some sort that I can use that would allow me to compare these values more like this:</p>
  
  <pre><code>if(a.equals(b).equals(c)) {
      doSomething();
  }
  </code></pre>