title: iterate through treeset of integers and store value from next() to an Integer variable
body: <p>I chopped down my program for simplicity, but it is necessary to store the value of next() in a variable because there are other things that I do in the iterator loop that check that value against some stuff. But I'm having trouble storing that value, I get an error saying "incompatible types".</p>
  
  <pre><code>import java.util.*;
  
  public class test
  {
      public static void main (String [] args)
      {
          String data="34 23 13 5 2 6 9 11";
          Scanner input=new Scanner(data);
          TreeSet set=new TreeSet();
          while (input.hasNextInt())
          {
              Integer num=new Integer(input.nextInt());
              set.add(num);
          }
          Iterator itr=set.iterator();
          while (itr.hasNext())
          {
              Integer num2=itr.next();
          }
      }
  }
  </code></pre>