title: Find out if an ArrayList contains more than one of an element
body: <p>I have an array list of usernames and an array list of passwords. Two or more users could have the same password.</p>
  
  <pre><code>ArrayList&lt;String&gt; u = new ArrayList&lt;String&gt;();
  ArrayList&lt;String&gt; p = new ArrayList&lt;String&gt;();
  </code></pre>
  
  <p>These arrays are populated from a file of the following format:</p>
  
  <pre><code>username  password
  </code></pre>
  
  <p>Like so;</p>
  
  <pre><code>String line = null;
  String split[] = null;
  while ((line = reader.readLine()) != null){
     split = line.split("\\s+");
     u.add(split[0]);
     p.add(split[1]);
  }
  </code></pre>
  
  <p>I have a brute force algorithm that generates passwords and I want to find if the passwords generated have a match.</p>
  
  <pre><code>String password = bruteForce()
  if (passwords.contains(password)){
      int index = passwords.indexOf(password);
      System.out.println("Username: " + usernames.get(index));
      System.out.println("Password: " + password);
  }
  </code></pre>
  
  <p>This works well if none of the users have the same password. If two users have the same password; it will just grab the first occurrence and print that, skipping the second user.</p>
  
  <p>I need a way to determine if there are multiple occurrences of the same password, get each occurrences index and then their matching username.</p>