Don't understand output of simple java program
<pre><code>public class Test10 
{ 
  public static void main( String[] args ) 
  { 
    Thing2 first = new Thing2( 1 ); 
    Thing2 second = new Thing2( 2 ); 
    Thing2 temp = second; 
    second = first; 
    first = temp; 
    System.out.println( first.toString() ); 
    System.out.println( second.toString() ); 
    Thing2 third = new Thing2( 3 ); 
    Thing2 fourth = new Thing2( 4 ); 
    third.swap1( fourth ); 
    System.out.println( third.toString() ); 
    System.out.println( fourth.toString() ); 
    second.setCount( fourth.getCount() ); 
    third = first; 
    System.out.println( third == first ); 
    System.out.println( fourth == second ); 
    System.out.println( first.toString().equals( third.toString() ) ); 
    System.out.println( second.toString().equals( fourth.toString() ) ); 
    System.out.println( first.toString() ); 
    System.out.println( second.toString() ); 
    System.out.println( third.toString() ); 
    System.out.println( fourth.toString() ); 
    first = new Thing2( 1 ); 
    second = new Thing2( 2 ); 
    first.swap2( second ); 
    System.out.println( first.toString() ); 
    System.out.println( second.toString() ); 
  } 
} 



class Thing2 
{ 
  private int count; 

  public Thing2( int count ) 
  { 
    this.count = count; 
  } 
  public int getCount() 
  { 
    return this.count; 
  } 
  public void setCount( int count ) 
  { 
    this.count = count; 
  } 
  public String toString() 
  { 
    String s = " "; 
    switch( this.count ) 
    { 
      case 1: 
        s = s + "first ";  
      case 2: 
        s = s + "mid "; 
        break; 
      case 3: 
        s = s + "last "; 
        break; 
      default: 
        s = s + "rest "; 
        break; 
    } 
    return s; 
  } 
  public void swap1( Thing2 t2 ) 
  { 
    int temp; 
    temp = this.getCount(); 
    this.setCount( t2.getCount() ); 
    t2.setCount( temp ); 
  } 
  public void swap2( Thing2 t2 ) 
  { 
    Thing2 temp; 
    Thing2 t1 = this; 
    temp = t1; 
    t1 = t2; 
    t2 = temp; 
  } 
} 
</code></pre>

<blockquote>
  <p>Given the following definition of class Thing2, what is the output of
  the Java application Test10?</p>
</blockquote>

<p>Hey guys, this is for one of my classes. There are two classes (listed above), Thing2 and Test10. This is the output, but I don't understand how to get to the output (i.e. what points to what and what's the order everything gets resolved in?). Thanks!</p>

<pre><code>mid
first mid
rest  
last
true
false
true
true 
mid  
last 
mid 
last
first mid
mid
</code></pre>
