title: Does Java 7 switch statement with String use equals() method?
body: <p>Java 7 supports switching with <code>Strings</code> like the code below</p>
  
  <pre><code>switch (month.toLowerCase()) {
  case "january":
      monthNumber = 1;
      break;
  case "february":
      monthNumber = 2;
      break;
  default: 
      monthNumber = 0;
      break;
  }
  </code></pre>
  
  <p>Does Java call the <code>equals()</code> method on each <code>String</code> case? Or it relies on <code>==</code> or <code>intern()</code>?</p>
  
  <p>Is this simply equivalent to:</p>
  
  <pre><code>String month = month.toLowerCase();
  if("january".equals(month)){
  monthNumber = 1;
  }else if("february".equals(month)){
  monthNumber = 1;
  }..
  </code></pre>
  
  <p>UPDATE:</p>
  
  <blockquote>
    <p>The String in the switch expression is compared with the expressions
    associated with each case label <strong>as if</strong> the <code>String.equals</code> method were
    being used.</p>
  </blockquote>
  
  <p>As the docs point out that the behavior is as if <code>equals()</code> is called.</p>