Use string in switch case in java
<p>I need to change the following if to switch case 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 ("orance".equals(value )) {
method4;
}
</code></pre>

<p>But i am not sure wat value is going to get.</p>
