JAVA类,别名问题

来源:互联网 发布:ubuntu安装vim 编辑:程序博客网 时间:2024/05/18 02:42

/*
  * 
  * @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


原创粉丝点击