Java console read input line by line and store in String array
<p>I have a question regarding reading strings from java console. When I give input of words each line until I stop with "stop" All those words should be stored in one array of string.</p>

<p>My input will be:</p>

<blockquote>
  <p>apple<br>
  Mango<br>
  grapes<br>
  stop -----> on stop the string ends here</p>
</blockquote>

<p>All the 3 fruit names will be stored in <code>temp</code>.</p>

<p>But when I type one word and want to type another by clicking enter to go to next line, it prints the output. </p>

<p>How should I modify this?</p>

<pre><code>Scanner scanner=new Scanner(System.in);
System.out.println("Enter the words");
String temp=scanner.nextLine();
</code></pre>