title: Using Cumulative Algorithm to Concatenate Strings of User Input
body: <p>I'm attempting to write a program that will ask a user how many pre-requisites a particular class has, ask for the name of each pre-requisite, and then output a list of the pre-requisites in a single line.</p>
  
  <p>My program is running without returning any errors; however, when it outputs the list of the pre-requisites, it only repeats the last one entered by the user instead of listing all of the pre-requisites entered.  I believe that this is because the value of the object is changing every time the user enters a new pre-requisite; however, I cannot figure out how to get it to save each value and concatenate them together for the output.</p>
  
  <p>The following code is what I'm using to collect the pre-requisites from the user</p>
  
  <pre><code> public static void getPrereqs() { 
   System.out.print("How many pre-requisites does the course have? ");
   numPrereqs = console.nextInt();
  
   console.nextLine();
  
   for (int i = 1; i &lt;= numPrereqs; i++) {
       System.out.print("List Pre-requisite #" + i + "? ");
       listPrereq = console.nextLine();
    }//Close for loop
  }//Close getPrereqs method
  </code></pre>
  
  <p>and this is the code I'm using to output the list (also includes recalling some other pieces of information but those are outputting correctly)</p>
  
  <pre><code>  public static void printToScreen () {
    System.out.println(courseCode + ": " + courseName);
    System.out.print("Pre-requisites: ");
    for (int i = 1; i &lt;= numPrereqs; i++) {
       System.out.print(listPrereq + ", ");
    }//Close for loop
    System.out.println();
    System.out.println("Total number of seats = " + TOTAL_SEATS);
    System.out.println("Number of students currently registered = " + studentsReg);
  
    openSeats = calcAvail(studentsReg);
  
    System.out.println("Number of seats available = " + openSeats);
    if (openSeats &gt;= 5) {
       System.out.println ("There are a number of seats available.");
    }//Close if loop
    else {
       if (openSeats &lt;= 0) {
          System.out.println ("No seats remaining.");
       }//Close if loop
       else {
             System.out.println ("Seats are almost gone!");
       }//Close else
    }//Close else statement
  }//Close printToScreen method
  </code></pre>
  
  <p>I have seen some threads discussing array lists; however, I am very unfamiliar with what this is and not comfortable using one at this time.  Is there a way to get the results I'm looking for using a cumulative algorithm?  </p>