when to use while loop rather than for loop
<p>I am learning java as well android. Almost everything that we can perform by while loop those things we can do in while loop. </p>

<p>I found a simple condition where using while loop is better than for loop</p>

<p>if i have to use the value of counter in my program then i think while loop is better than for loop</p>

<p><strong>Using while loop</strong></p>

<pre><code>int counter = 0;
while (counter &lt; 10) {
    //do some task
    if(some condition){
        break;
    }
}
useTheCounter(counter); // method which use that value of counter do some other task
</code></pre>

<p>In this case I found while loop is better than for loop because if i want to achieve the same in for loop i have to assign the value of counter to another variable.</p>

<p><strong>But is there any specific situation when while loop is better than for loop</strong></p>
