Calling a base class constructor from derived class in Java

前端 未结 3 1425
迷失自我
迷失自我 2020-12-18 18:43

I have a class as follows:

public class Polygon  extends Shape{

    private int noSides;
    private int lenghts[];

    public Polygon(int id,Point center,         


        
3条回答
  •  一整个雨季
    2020-12-18 18:50

    Your constructor should be

    public Regularpolygon extends Polygon{
    
    public Regularpolygon (int id,Point center,int noSides,int lengths[]){
    super(id, center,noSides,lengths[]);
    
    // YOUR CODE HERE
    
    }
    
    }
    

提交回复
热议问题