title: Why do I have to write twice to add an input in the Arraylist?
body: <pre><code>public static void main(String[] args) {
      List&lt;String&gt; arrayList = new ArrayList&lt;&gt;();
      Scanner input = new Scanner(System.in);
      do {
          System.out.println(&quot;Enter a product&quot;);
          String product = input.nextLine();
          arrayList.add(product);
      }
      while (!input.nextLine().equalsIgnoreCase(&quot;q&quot;));
  
      System.out.println(&quot;You wrote the following products \n&quot;);
      for (String naam : arrayList) {
          System.out.println(naam);
      }
  }
  </code></pre>
  <p>I'm trying to get some input from the user and store them into arraylist. The problem is I have to write the item twice to add an item into the list. I can't figure out why!</p>