【发布时间】:2020-07-12 00:23:52
【问题描述】:
我有一个类扩展了 Java 中的另一个类
我需要构造函数来运行超级ctor
这是我的基本代码:
public class Polygon implements Geometry {
public Polygon(Point3D... vertices) {
......
}
}
我想从子类中调用它
public class Triangle extends Polygon {
//ctor
public Triangle(Point3D point3d, Point3D point3d2, Point3D point3d3){
List<Point3D> _temp = null;
_temp.add(point3d);
_temp.add(point3d2);
_temp.add(point3d3);
super(_temp);
}
}
我该怎么做,因为我收到错误“构造函数调用必须是构造函数中的第一个语句”,但我需要构建 ctor
谢谢
【问题讨论】:
标签: java