public class Demo03 {
public static void main(String[] args) {
int a = 1;
System.out.println(a);
Demo03.change(a);
System.out.println(a);
}
public static void change(int a){
a=10;
}
}
两次输出的结果均为1
public class Demo02 {
public static void main(String[] args) {
Person person = new Person();
System.out.println(person.name);
Demo02.change(person);
System.out.println(person.name);
}
public static void change(Person person){
person.name="theshy";
}
}
class Person{
String name;
}
第一次输出结果为null 第二次为theshy
原文:https://www.cnblogs.com/rfcaTheshy/p/14802175.html