package hello;
public class PeopleAndMoney {
public static void main(String[] args) {
// TODO Auto-generated method stub
double y=0.8;
People zhang=new People();
zhang.setMoney(8888);
A a=new A();
System.out.println("在方法f被调用之前对象zhang的money是:"+zhang.money+" y的值是"+y);
a.f(y,zhang);
System.out.println("在方法f被调用之后main方法中y的值仍然是:"+y);
System.out.println("在方法f被调用之后main方法中对象zhang的money是:"+zhang.money);
}
}
class People {
int money;
void setMoney(int n) {
money = n;
}
}
class A {
void f(double y, People p) {
y = y + 1;
p.setMoney(100);
System.out.println("参数y的值是:" + y);
System.out.println("参数对象p的money是:" + p.money);
}
}
![](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvMTMyMjQ5OS8yMDE4MTAvMTMyMjQ5OS0yMDE4MTAxMzE3MTk0NTQ3OC0xNzIzMzQxNzM2LnBuZw?x-oss-process=image/format,png)