Dea All,
I have the following:
class test {
int x = 6;
int y = 7;
private int getX() {
return x;
}
private int getY() {
return y;
}
public test copy() {
test myTest = new test();
myTest.x = getX();
myTest.y = getY();
return myTest;
}
}
However, when I then execute:
test a = new test();
test b = a.copy();
b.x = 17;
System.out.println(a.x);
The result is still 17. However, shouldn't deep copying prevent this?
Anybody who can help me?