title: Enter multiple strings on one line with a sentinel value into an array (java)
body: <p>I'm trying to enter multiple strings into an array but they all have to be on the same line and stop when the sentinel value is entered. This is what I have so far.</p>
  <pre><code>        String [] courses = new String [5];
          for (int k = 0; !(input.next().equals(&quot;xxx&quot;)); k++) {
              courses[k] = input.next();
          }   
  </code></pre>
  <p>It seems like the for loop isn't looping, when I check the array after it will only have the last string before &quot;xxx&quot;, and none of the previously entered ones. All of the input must be on one line.</p>