0

String.charAt、PasswordGenerator.matchCharAt、およびDriver.mainで文字列インデックスが範囲外であることを示すエラーが発生し続けます。それが正確に何を意味するのかわかりません。また、私の文字は、すでにインスタンス化したstringbuilderクラスの1行に追加されません。それは文字列インデックスエラーが原因なのか、それとも私のせいなのか疑問に思いました。

public class Driver {

    public static void main(String[] args) {
        int length=0;
        int MaxNumber=100;
        StringBuilder password = new StringBuilder();

        do {
            if (PasswordGenerator.matchLength (length))
                System.out.println("The length of the character is " + length);
            length++;                                     // length is randomly picked
        } while (length < MaxNumber );   // or <100

        int index = 0;
        char f = 0;

        for (int d = 0; d < 127 || ; d++) {
            if  (PasswordGenerator.matchCharAt(f, index))
                d = (char) index;
            char aChar = (char)d;
            password.append(aChar);
            System.out.println("Password is: " + aChar);
            index++;

        }
    }
}
4

1 に答える 1

2

idx0 から 127 の間で変化するため、エラーが発生しています。 からのパスワードPasswordGeneratorはおそらくそれほど長くありません。たとえば、インデックス 57 に一致するかどうかを確認する前に、57 がパスワードの長さより短いかどうかを確認する必要があります。

あなたの仕事は、ジェネレーターが保存するパスワードを推測することですか? 次に、これを行う必要があります。

Get to know the length of the password.
For each index from 0 upto but excluding the length:
    Guess the character at that index.
于 2012-04-28T00:58:24.540 に答える