I think that everyone will agree that the following class achieves data abstraction (hiding of its internal representation):
class A {
private List x = new ArrayList();
public List getX() {
return this.x;
}
public void setX(List x) {
this.x = x;
}
}
But could we say the same about the following one, which uses a class (instead of an interface like in the previous class) as a field type, parameter type, and return type?
class B {
private ArrayList x = new ArrayList();
public ArrayList getX() {
return this.x;
}
public void setX(ArrayList x) {
this.x = x;
}
}