title: How to fix java.util.NoSuchElementException
body: <p>I'm doing Homework and I'm inputting values via the console using. The program is not nearly finished and I'm just trying to get the input system to work. I'm running into a problem where I've seen other people run into with other pieces of code but I don't know how to implement them in this context.</p>
  
  <p>It's inputted in this format:
  4 - number of lines of data
  5 6 - Datapeices
  5 6 - Datapeices
  5 6 - Datapeices
  5 6 - Datapeices</p>
  
  <p>I'm trying to make an array w/ line 1 * 2 length and proceed to stor that in the array. Every other datapeice I'm going down a line.</p>
  
  <p>import java.io.*;</p>
  
  <p>import java.util.StringTokenizer;</p>
  
  <pre><code>    int arr[];
      int x = 0;
  
      BufferedReader br = new BufferedReader(newInputStreamReader(System.in));
      StringTokenizer st = new StringTokenizer(br.readLine());
      arr = new int [Integer.parseInt(st.nextToken())*2];
  
      for (int i = 0; i &lt; arr.length; i++) {
          if ((i%2)==1) {
              x = Integer.parseInt(st.nextToken());
              st = new StringTokenizer(br.readLine());
          } else {
              x = Integer.parseInt(st.nextToken());
          }
          arr[i] = x;
      }
      System.out.println(arr.toString());
  }
  </code></pre>