Java try-catch inside of while loop or outside
<p>What is the difference between:</p>

<pre><code>while( true ) {
    try {
        // something 
    } catch( Exception e ) {
        break; 
    }
}
</code></pre>

<p>and </p>

<pre><code>try {
    while( true ) {
    // something 
    // break; // eventually
    }
} catch( Exception e ) {

}
</code></pre>

<p>Does the former run a try-catch on every iteration or does the compiler generate the same code.
Which is preferred?</p>

<p>EDIT: break; was removed from catch block in second example since there is no need.</p>
