Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9195453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:37:51+00:00 2026-06-17T21:37:51+00:00

In the following code the for loop is never executed. I have attempted to

  • 0

In the following code the for loop is never executed. I have attempted to fix the problem with breakpoints and watches. The correct length for the cipher text is returned, however the for loop does not increment until int i >= ciphertext.length(). In fact, nothing seems to execute past the ‘Debug’ message.

private void decrypt_btnActionPerformed(java.awt.event.ActionEvent evt) {                                            


    String alphabet= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    String ciphertext="fRcXFBxXTRJ";


    status_label.setText( "Decryption has begun" );

    JOptionPane.showMessageDialog(null,"ciphertext-length: " + ciphertext.length() + "\n" + ciphertext,"Debug", JOptionPane.INFORMATION_MESSAGE);

    for (int i = 0; i>=ciphertext.length(); i--){

        System.out.println("inc:" + i);

        String cipher_current_char = getLetterAtIndex(ciphertext, i);
        int pos_char_in_alphabet = getIndexAtLetter(alphabet, cipher_current_char);


        if(pos_char_in_alphabet-2<0){

            plain_ta.setText(getLetterAtIndex(alphabet, (alphabet.length()+(pos_char_in_alphabet -2)+1 ) ));

            status_label.setText( 100/i + "%");



        }else{

            cipher_current_char = getLetterAtIndex(ciphertext, i);

            pos_char_in_alphabet = getIndexAtLetter(alphabet, cipher_current_char);

            plain_ta.setText(getLetterAtIndex(alphabet, (pos_char_in_alphabet-2)));

            status_label.setText( 100/i + "%");

        }
    }
}                          
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:37:52+00:00Added an answer on June 17, 2026 at 9:37 pm
    for (int i = ciphertext.length()-1; i>=0; i--){
    

    You need to work backwards. Also note the -1, you need it to avoid out of bounds exceptions (indexes start at 0 and go to length -1 ).

    Always trace your loop out loud with paper and pencil when you’re stuck, it always helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code inside a loop: Range(N & i + 1).Formula =
The following code returns the error from the For Each loop. I have similar
I have the following rails code in a loop that has a link for
I have a following code in a most inner loop of my program struct
i have the following code ..i need to loop through end of the file
I have the following piece of code and in the j for loop the
I wrote the following loop since I have to repeat the same/similar code 25
Following code is generated by a for loop. <form action=saveresponse.php method=POST name=mainForm> <input class=cbox_yes
Within a for loop, I'm using the following code to convert from one date
I would like to optimize the following code in R. This loop takes a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.