How to exit the loop?
<p>I have below code. I wrote a for loop and inside that I have switch statement. The switch has two cases and if <code>i==someOtherValue</code> is true then entire loop should exit. </p>

<pre><code>for (//iterate over elements){
    int i = someValueTakenFromLoop;
    if(i==someOtherValue){

        switch(i){
            case 5:
                //some logic
                break;
            case 6:
                //some logic
                break;
         }
     }
 }
</code></pre>

<p>While iterating if <code>i==someOtherValue</code> is true then it should exit the loop. Do i need to keep break statement out side switch?.</p>

<pre><code>    for(//iterate over elements){
        int i = someValueTakenFromLoop;
        if(i==someOtherValue){
            switch(i){
                case 5:
                    //some logic
                    break;
                case 6:
                    //some logic
                    break;
            }
            break;
         }
     }
</code></pre>

<p>Thanks!</p>
