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; 
  } 
} 
クラス Thing2 の次の定義が与えられた場合、Java アプリケーション Test10 の出力は何ですか?
こんにちは、これは私のクラスの 1 つです。Thing2 と Test10 の 2 つのクラス (上記) があります。これは出力ですが、出力に到達する方法がわかりません (つまり、何が何を指し、すべてが解決される順序は何ですか?)。ありがとう!
mid
first mid
rest  
last
true
false
true
true 
mid  
last 
mid 
last
first mid
mid