值传递
public static void main(String[] args) {
int a=1;
System.out.println(a);
Demo04.change(a);
System.out.println(a);
}
//返回值为空
public static void change(int a){
a =10;
}
引用传递
public static void main(String[] args) {标签:Person,System,传递,person,static,引用,public,out From: https://www.cnblogs.com/yangruoting-01/p/17038532.html
//person 是一个对象,指向的------>Person person = new Person();这是一个具体的人,可以改变属性
Person person = new Person();
System.out.println(person.name);//nall
Demo04.change(person);
System.out.println(person.name);
}
public static void change(Person person){
person.name="yang";
}
static class Person{
String name;//nall
}