title: NoSuchElementException with Java.Util.Scanner with array
body: <p>I m very new to java and don't know why I'm getting this error when I run below program</p>
  
  <p><strong>program :</strong> this program basically read no of input N in first line and then scan each number and store it in array <strong>arr</strong> and display it.</p>
  
  <p>range of N is : <code>0&lt;N&lt;10^6</code></p>
  
  <p>input numbers can be long so that I used <strong>long array</strong> in the program.</p>
  
  <pre><code>import java.io.*;
  import java.util.*;
  import java.text.*;
  import java.math.*;
  import java.util.regex.*;
  
  public class Solution {
  
  public static void main(String[] args) {
      /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
      Scanner sc = new Scanner(System.in);
      long no = sc.nextLong();
  
      if(no &gt; 1000000 || no &lt; 1)
                   System.exit(0);
  
  
      long arr[] = new long [(int)no];
  
  
      for(int i=0;i&lt;(int)no;i++) {
  
          arr[i] = sc.nextLong();
          System.out.println(arr[(int)i]);
  
      }
  }
  }
  </code></pre>
  
  <p>input values : <a href="http://pastebin.com/abpjy2fd" rel="nofollow">here</a> you find input values</p>
  
  <p><strong>output :</strong></p>
  
  <p><strong>Runtime Errors</strong></p>
  
  <pre><code>Exception in thread "main" java.util.NoSuchElementException
      at java.util.Scanner.throwFor(Scanner.java:907)
      at java.util.Scanner.next(Scanner.java:1530)
      at java.util.Scanner.nextLong(Scanner.java:2265)
      at java.util.Scanner.nextLong(Scanner.java:2225)
      at Solution.main(Solution.java:23)
  </code></pre>
  
  <p><strong>rest of output is</strong> <a href="http://pastebin.com/mBLsuGKn" rel="nofollow">here</a></p>