Java:
public class Base {
private int a
protected int b;
public Base(int a,int b) {
this.a = a;
this.b = b;
}
public int getA() {
return a;
}
public int getB() {
return b;
}
}
...
Base foo = new Base(1,2);
Base bar = new Base(3,4);
( , ) foo bar
, ,
public class Base {
private int a
protected int b;
public Base(int a,int b) {
this.a = a;
this.b = b;
}
public int getA() {
return a;
}
public int getB() {
return b;
}
public void changeB(int newB,Base other) {
other.b = newB;
}
}
...
Base foo = new Base(1,2);
Base bar = new Base(3,4);
foo.changeB(5,bar);
changeB other [*], , . other unchangable, Java - .
[*} , Base , , .