title: cannot read last line from console using scanner in java
body: <p>This question is already asked, but I am not clear with the answers.
  Please check my code below. I am pasting multiple lines in console without pressing <kbd>enter</kbd> button. <code>Scanner</code> is not reading the last line, but when I press <kbd>enter</kbd> it reads it.</p>
  
  <p>My input is:</p>
  
  <blockquote>
    <p>2<br>
    4 3<br>
    -1 -3 4 2<br>
    4 2<br>
    0 -1 2 1  </p>
  </blockquote>
  
  <p>Output with out enter:</p>
  
  <blockquote>
    <p>243-1-34242</p>
  </blockquote>
  
  <p>When I press enter it is showing last line.</p>
  
  <pre><code>public static void main(String[] args)
  {
      Scanner scan = new Scanner(System.in);
      while(scan.hasNext())
      {
          System.out.print(scan.next());
      }
  }
  </code></pre>
  
  <p>Please try in Eclipse.</p>