0

SO i made a CharSequence[] array with all the two consecutive uppercase letters. Why is this code not returning the correct values?

public static boolean containConsecCaps(String passw)
{
    CharSequence[] consec = {"AA","AB","AC","AD","AE","AF", ... "ZZ"};
    boolean contain = false;
    String pass = passw;
    for (int i = 0; i <= 675; i++)
    {
        contain = pass.contains(consec[i]);
        if (contain == true)
            break;
    }
    return contain;
}

and in the main string, this syntax:

while (consec != false)
          {
              //Consec.setPassword(password.getPassword());
              consec = Consec.containConsecCaps(password.getPassword());
              if (consec == false)
                  break;
              else
                  password.setPassword(reader.readLine("Error. Please enter a password with no consecutive letters:        "));
          }

now everything else in the three classes work. This is the only problem and it seems to get stuck in the else. Why is it not testing all of the array char's then returning true or not? It gets stuck in a loop if i enter: AApassword.1 , which fits all the other criteria, except the two consecutive capitals. So then i enter: aApassword.1 , which should fit ALL of the criteria, but it still prints out the else statement, instead of breaking the while loop. Can anyone help me?

4

0 回答 0