public class TestReferenceType {
public static void main(String[] args) {
Student student = new Student();
student.id = 2000;
method(student);
System.out.println("main:" + student.id);//2000
}
// 引用数据类型直接传类和引用变量
public static void method(Student student) {
student.id = 1000;
System.out.println(student.id);//1000
}
}
结果:
1000
main:1000