Return in the middle of a loop
<p>I have to write a function to remove a element from a linkedlist (mine, not that of Collections framework), so here is my first attempt :</p>

<pre><code>public void remove(E element) {
    Cell&lt;E&gt; cell = sentinel;
    int i = 0;
    while (i &lt; count) {
        if (cell.getElement().equals(element)) {
            cell.getPrevious().setNext(cell.getNext());
            --count;
            return;
        }
        ++i;
        cell = cell.getNext();
    }
}
</code></pre>

<p>My question is : is using <code>return</code> like this is good ?
More generally, when the condition is checked and there is no point running the following instructions, then it made sense to me to use <code>return</code> :</p>

<pre><code>void func() {
    while (condition) {
        if (something) {
            instructions;
            return;
        }
        more instructions;
    }
}
</code></pre>

<p>But since it was not very readable and everybody says that readability is the priority in java, I had to think of another approach. So I changed the condition and used a additional boolean.</p>

<pre><code>public void remove(E element) {
    boolean found = false;
    Cell&lt;E&gt; cell = sentinel;
    int i = 0;
    while (!found &amp;&amp; i &lt; count) {
        if (cell.getElement().equals(element))
            found = true;
        else {
            ++i;
            cell = cell.getNext();
        }
    }
    if (found) {
        cell.getPrevious().setNext(cell.getNext());
        --count;
    }
}
</code></pre>

<p>In that way, there is no weird <code>return</code> and instructions are executed only when they have to be. If I am confronted to this again, I think I will have to re-write the loop like this. 
Maybe I am totally wrong and the first approach is better. What do you think of it ?</p>