title: Java boolean method with for loop
body: <p>Hey I'm trying to do a for loop inside a method which should return a boolean. However I keep getting an error. Basically the array can get very big and I wish for this to check through the whole array to look for the username and password.</p>
  
  <pre><code>public class Users {
      private String username;
      private String password;
      private String[][] accounts = { { "user1", "pass1" }, { "user2", "pass2" } };
  
      public Users(String username, String password) {
          this.username = username;
          this.password = password;
      }
  
      public boolean check() {
  
          for (int i = 0; i &lt; accounts.length; i++) {
              if ((username.equals(accounts[i][0])) &amp;&amp; (password.equals(accounts[i][1]))) 
                  return true;
              else 
                  return false;
          }
      }
  
  }
  </code></pre>