Java simple for循环不会迭代

时间:2013-01-21 03:24:41

标签: java for-loop loops

在执行期间,调用该方法,整数i在屏幕上显示为0。但是,for循环内部没有输出,表明for循环没有执行。我还用断点测试了它,并获得了相同的结果。任何帮助表示赞赏。

private void decrypt_btnActionPerformed(java.awt.event.ActionEvent evt) {
    int ciphertext_length = Ciphertext().length();
    String decrypted_char = "";
    int i = 0;

    System.out.println("increment" + i);    

    try {
        for (i = 0; i == ciphertext_length; i++) {

            System.out.println("test" + i);

            String cipher_current_char = getLetterAtIndex(Ciphertext(), i);
            int pos_char_in_alphabet = getIndexAtLetter(Alphabet(), cipher_current_char);

            decrypted_char = decrypted_char +
                getLetterAtIndex(Alphabet(), pos_char_in_alphabet - 5);

            status_label.setText(100 / i + "%");
        }
    } catch (Exception e) {
        e.getMessage();
    }

    plain_ta.setText(decrypted_char);
}

1 个答案:

答案 0 :(得分:7)

  for (i = 0; i==ciphertext_length; i++){

应该很可能是

  for (i = 0; i<ciphertext_length; i++){