Hej, w trakcie ogarniania modyfikatorów dostępu zrobiłem takie coś.
class Base {
private int x;
private int y;
Base(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
}
class Child extends Base {
Child(int x, int y) {
super(x, y);
}
}
W konstruktorze Child
wywołuję konstruktor klasy Base
jednak ma ona pola prywatne. Dlaczego potem w klasie Child
mogę normalnie operować na x
oraz y
skoro ich nie dziedziczę? (są private). Czy super
zmienia cos w temacie?