类 / 继承

class Shape {
    public int lineCount;

    public Shape(int lineCount) {
        this.lineCount = lineCount;
    }
}

class Square extends Shape {
    public int sideLength; 

    public Square(int sideLength) {
        super(4);
        this.sideLength = sideLength;
    }
}

var square = new Square(5);
//square.lineCount is 4

System.out.println("lineCount is " + 
    square.lineCount);