title: How to print objects from a TreeSet
body: <p>I want to print the instance variables of the objects I stored in my TreeSet. </p>
  
  <p>So given an Object with three instance variables, I want to iterate over the Objects in my TreeSet and print their ivars but:</p>
  
  <pre><code>while ( iter.hasNext() )
  {
    System.out.println( iter.next().getIvar1 );
    System.out.println( iter.next().getIvar2 );
  }
  </code></pre>
  
  <p>gets me the ivar1 of the first object and the ivar2 of the second object.
  And with all my searching I found no way of printing all the ivars of one object before moving the iterator to the next object like:</p>
  
  <pre><code>while ( iter.hasNext() )
  {
    System.out.println( iter.hasNext().getIvar1() );
    System.out.println( iter.getIvar2 );
    System.out.println( iter.getIvar3 );
    System.out.println( iter.hasNext().getIvar1() );
    ....
  }
  </code></pre>
  
  <p>Any ideas on how to implement that? </p>
  
  <p>Thanks in advance! =)</p>