调用与引用
# 调用与引用
## 调用是在同一个Demo里,调用方法等
```public class oopDemo5 {
public static void main(String[] args) {
Perosn perosn = new Perosn();
System.out.println(perosn.name);
change(perosn);
System.out.println(perosn.name);
}
public static void change(Perosn perosn){
perosn.name = "luo";
}
}
## 引用是在不同的Demo里,引用属性等
public class oopPet {
public String name;
public int age;
public void shout(){
System.out.println("别叫了");
}
}
public class oopDemo8 {
public static void main(String[] args) {
oopPet oopPet = new oopPet();
oopPet.name = "小罗";
oopPet.age = 3;
oopPet.shout();
System.out.println(oopPet.name);
System.out.println(oopPet.age);
oopPet cat = new oopPet();
cat.name = "cojob";
cat.age = 1;
cat.shout();
System.out.println(cat.name);
System.out.println(cat.age);
}
}