/*
*测试传址引用的实质
*/
public class Student
{
String strName;
public static void main(String[] args)
{
Student aStudent = new Student();//得到对象Student类的一个句柄aStudent
aStudent.setStudentName("张楠");
System.out.println("aStudent name is " + aStudent.getStudentName());
Student bStudent = aStudent;//将aStudent句柄复制给nextStudent
bStudent.setStudentName("唐僧");
System.out.println("bStudent name is " + bStudent.getStudentName());
String name = aStudent.getStudentName();//再看一下句柄aStudent的内容是否改变
System.out.println("after bStudent the aStudent name is " + name);
}
public void setStudentName(String name)
{
strName = name;
}
public String getStudentName()
{
return strName;
}
}