JAVA类,别名问题

/*
  * 
  * @author caryt
  *
  */
class test1{
String thh="caryt1";
}

/**

 * 
 * @author caryt
 *
 */
public class test {
   static void test2(test1 t3){
  t3.thh="caryt3";
   }
/**
* @param args
*/

public static void main(String[] args) {
// TODO Auto-generated method stub
test1 t1=new test1();
test1 t2=new test1();

t2.thh="caryt2";

System.out.println("t1:"+t1.thh+" t2:"+t2.thh);

t1=t2;

System.out.println("t1:"+t1.thh+" t2:"+t2.thh);

test2(t1);

System.out.println("t1:"+t1.thh+" t2:"+t2.thh);

}

}

out: t1:caryt1 t2:caryt2
t1:caryt2 t2:caryt2
t1:caryt3 t2:caryt3


posted on 2013-06-27 09:59  caryt  阅读(140)  评论(0)    收藏  举报

导航