title: What is the best way to exit loop in Java?
body: <p>What is the best way to end a <code>loop</code> in Java?</p>
  
  <p>This:</p>
  
  <pre><code>boolean exit = false;
  
  while((a &lt; 5) &amp;&amp; (exit = false)){
     if(a == 3)
         exit = true;
     else
         a++;
  }
  </code></pre>
  
  <p>Or this:</p>
  
  <pre><code>while((a &lt; 5){
     if(a == 3)
         break;
     else
         a++;
  }
  </code></pre>