/**
* @param args
*/
public static void main(String[] args) {
B b=new B();
A a1=new A(b);
A a2=new A(b);
a1.add();
System.out.print(a2.b.getA());
}
}
class A{
public B b=new B();
public A(B b){
}
public void add(){
b.setA(b.getA()+1);
}
}
class B{
public int a=10;
public int getA(){
return a;
}
public void setA(int a){
this.a=a;
}
}
能不能达到实验效果啊