title: Use string in switch case in java
body: <p>I need to change the following <code>if</code>'s to a <code>switch</code>-<code>case</code> while checking for a <code>String</code>, to improve the cyclomatic complexity.</p>
  
  <pre><code>String value = some methodx;
  if ("apple".equals(value)) {
      method1;
  }
  
  if ("carrot".equals(value)) {
      method2;
  }
  
  if ("mango".equals(value)) {
      method3;
  }
  
  if ("orange".equals(value)) {
      method4;
  }
  </code></pre>
  
  <p>But I am not sure what value I'm going to get.</p>