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 7000563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:41:18+00:00 2026-05-27T20:41:18+00:00

I am trying to use a do…while loop that loops based on the id’s

  • 0

I am trying to use a do…while loop that loops based on the id’s in my array. I am a little new to using the do while loop, so am having some trouble incorporating the array into the thing. Here is my relevant code:

    String studentId   = StringUtils.defaultString(request.getParameter("Student_ID"));
    String studentId1  = StringUtils.defaultString(request.getParameter("Student_ID1"));   
    String studentId2  = StringUtils.defaultString(request.getParameter("Student_ID2"));
    String studentId3  = StringUtils.defaultString(request.getParameter("Student_ID3"));
    String studentId4  = StringUtils.defaultString(request.getParameter("Student_ID4"));
    String studentId5  = StringUtils.defaultString(request.getParameter("Student_ID5"));
    String studentId6  = StringUtils.defaultString(request.getParameter("Student_ID6"));
    String studentId7  = StringUtils.defaultString(request.getParameter("Student_ID7"));
    String studentId8  = StringUtils.defaultString(request.getParameter("Student_ID8"));
    String studentId9  = StringUtils.defaultString(request.getParameter("Student_ID9"));


    String[] studentArray;
    studentArray = new String [15];
        studentArray[0]  = studentId;          studentArray[1]  = studentId1;
        studentArray[2]  = studentId2;         studentArray[3]  = studentId3;
        studentArray[4]  = studentId4;         studentArray[5]  = studentId5;
        studentArray[6]  = studentId6;         studentArray[7]  = studentId7;
        studentArray[8]  = studentId8;         studentArray[9]  = studentId9;


do {
    // blah blah blah
} while (  // Here is where I want to tell it to loop for every student in my array.  It should not run for id's that are empty strings(*if possible));

See comments for a more clear explanation. The StringUtils.defaultString that is used when i am getting my parameters will give me an empty string if the param receives a NULL. So if possible I would like to take that into account, and not run my “do {}” statements when the particular array ID is an empty string. Thanks in advance for the help, and if you have any questions, please ask.

  • 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-05-27T20:41:18+00:00Added an answer on May 27, 2026 at 8:41 pm

    This is better done using a for each loop:

    for(String x:studentArray){
      // do what you want to do with x
    }
    

    To skip over values that are null, just insert an if check at the beginning of the loop and continue if x is empty.

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

Sidebar

Related Questions

Hi I'm trying use a mixin to define some method using define_method. I would
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
I am trying use javascript regular expressions to do some matching and I found
I'm a little confused here, I am trying use a partial view in a
I am trying use a javascript function while passing php variables in it. For
I am trying use a javascript function while passing php variables in it. For
I am trying use MySql and Entity Framework, using Connector/Net 6.1 with this as
Anyone know how to create a cvCreateStructuringElementEx using a image? I'm trying use opencv.cv.cvCreateStructuringElementEx()
I'm trying use make a div's background transparent using a mixture of CSS3 rgba()
I'm trying use eco for client-side templating. I have multiple .eco templates that I'd

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.