title: How to add scanner input to a Queue and exit out of loop after input read
body: <p>I'm trying to add scanner inputs into an <code>ArrayList</code>, but I can't exit out the loop after I have entered the inputs. How can I exit this loop after I'm done entering inputs?</p>
  <pre><code>ArrayList&lt;String&gt; inputs = new ArrayList&lt;&gt;();
  int i = 0;
  while(scan.hasNext()){//while there is an hasNext
      inputs.add(scan.next());// add to the inputs array of queue
      i++;
  }scan.close()
  </code></pre>
  <p>;</p>