title: Reading a line of integers from user - Java
body: <p>This program should take a line from the user, such as "1 2 5 8 3", and use that to build a tree. Having trouble separating out each number as an integer. Read input using <code>scanner.next()</code>, tried using a string split, and then parsing each string into an integer. But I check the tree and it's empty. Any thoughts on what is going wrong?</p>
  
  <pre><code>System.out.println("Please enter the inital values. Press enter when done.");
  String input = scan.next(); // gets the entire line
  String[] values = input.split(" "); // split by spaces
  int[] intVals = new int[values.length]; //array to store integers
  //string to int and stores in integer value array
  for (int i = 0; i &lt; values.length; i++) {
      intVals[i] = Integer.parseInt(values[i]);
  }
  //goes through integers and adds them to tree
  for (int j = 0; j &lt; intVals.length; j++) {
      oak.add(j);
  }
  </code></pre>