关于传值和传引用的问题
public   class   SwaperTest{ 
 	public   void   swap1(int   a,int   b){ 
 		int   temp=0; 
 		temp=a; 
 		a=b; 
 		b=temp; 
 	} 
 	public   void   swap2(Integer   i1,Integer   i2){ 
 		Integer   temp=null; 
 		temp=i1; 
 		System.out.println(temp); 
 		i1=i2; 
 		System.out.println(i1+ "\t "+i2); 
 		i2=temp; 
 		System.out.println(i1+ "\t "+i2); 
 	}  	 
 	public   static   void   main(String[]   args){ 
             	int   num1=10; 
             	int   num2=20;              	 
             	Integer   n1=new   Integer(num1); 
             	Integer   n2=new   Integer(num2);              	 
             	SwaperTest   st=new   SwaperTest(); 
             	st.swap1(num1,num2); 
             	System.out.println   (num1+ "             "+num2);              	 
             	st.swap2(n1,n2); 
             	System.out.println   (n1+ "             "+n2); 
             } 
 }     
 打印结果为:         10               20 
                                           10               20     
 public   class   SwaperTest2{ 
 	public   int   num=10; 
 }   
 class   Swap{ 
 	public   void   swapMethod1(int   num1,int   num2){ 
 		int   temp=0; 
 		temp=num1; 
 		num1=num2; 
 		num2=temp; 
 	} 
 	public   void   swapMethod2(SwaperTest2   st1,SwaperTest2   st2){ 
 		int   temp=0; 
 		temp=st1.num; 
 		st1.num=st2.num; 
 		st2.num=temp; 
 	} 
 } 
 class   Tester{ 
 	public   static   void   main(String[]   args){ 
             	SwaperTest2   st1=new   SwaperTest2();st1.num=20;	 
             	SwaperTest2   st2=new   SwaperTest2();st2.num=40;              	 
             	Swap   s=new   Swap(); 
             	s.swapMethod1(st1.num,st2.num); 
             	System.out.println(st1.num+ "                   "+st2.num);              	 
             	s.swapMethod2(st1,st2); 
             	System.out.println(st1.num+ "                   "+st2.num);              		 
             } 
 }     
 打印结果为:         20               40 
                                           40               20     
 请大侠解释,谢谢!
------解决方案--------------------学过C++都知道应用其实就是简化的指针,所以引用本省是个地址,这和他所指向的对象是不同的,其函数实传值和传地址传入的都是拷贝并不是本省,举个例子看看。   
 (1) 定义两格对象 
  Integer n1=new Integer(1);  n1-> 对象1   (-> 表示指向) 
  Integer n2=new Integer(2);  n2-> 对象2   
 (2)传入函数swap(n1,n2) 
      这时只是复制了n1,n2引用,对象1和对象2没有复制。 
 (3) 当交换的时候只是交换了复制后的n1,n2的指向(这里复制后用n1 ',n2 '表示) 
      这时  n1 '-> 对象2   n2 '-> 对象1