public class Test {
public static void main(String[] args) {
Sub sub = new Sub();
System.out.println(sub.getWidth());
}
}
class Sub extends Base {
private Dimension size;
public Sub() {
this.size = new Dimension(50, 50);
}
public Dimension getSize() {
return size;
}
}
class Base {
private int width;
private int height;
private Dimension size = new Dimension(20, 20);
Base() {
this.width = getSize().width;
this.height = getSize().height;
}
Dimension getSize() {
return size;
}
int getWidth() {
return width;
}
int getHeight() {
return height;
}
}
Login in to like
Login in to comment