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
原文地址:https://www.cnblogs.com/Koma-vv/p/9503248.html
时间: 2024-10-20 11:23:07