title: Stopping an iteration of an ArrayList in Java
body: <p>I'm iterating an <code>ArrayList</code> of clients named <strong>clientList</strong> that contains clients from the class <code>Client (user,pass)</code></p>
  
  <pre><code>ArrayList&lt;Client&gt; clientList= new ArrayList&lt;Client&gt;();
  </code></pre>
  
  <p>Here's the iteration. I want to stop the iteration if it founds a given user (user) and if the password (pass) matches:</p>
  
  <pre class="lang-java prettyprint-override"><code>            for (Client c : clientList) {
                  userA = c.getUser();
                  if (userA.equals(user)) {
                      passA = c.getPassword();
                      if (passA.equals(pass)) {
                          loginOK = true;
                          found= true;
                      }
  </code></pre>
  
  <p>I was trying the following <strong>while (found == false)</strong> but it's get stucked if it doesnt find an user on the ArrayList:</p>
  
  <pre class="lang-java prettyprint-override"><code>        while (found == false) { /
              for (Client c : clientList) {
                  userA = c.getUser();
                  if (userA.equals(user)) {
                      passA = c.getPassword();
                      if (passA.equals(pass)) {
                          loginOK = true;
                          found= true;
                      }
                  }
              }
          }
  </code></pre>