我正在阅读一些代码。在构造函数中,它具有super(),但类实现的接口(interface)当然没有构造函数。那么它指的是哪个super()?
public class BoundingBox implements IBoundingVolume {
public BoundingBox() {
super();
mTransformedMin = new Number3D();
mTransformedMax = new Number3D();
mTmpMin = new Number3D();
mTmpMax = new Number3D();
mPoints = new Number3D[8];
mTmp = new Number3D[8];
mMin = new Number3D();
mMax = new Number3D();
for(int i=0; i<8; ++i) {
mPoints[i] = new Number3D();
mTmp[i] = new Number3D();
}
}
public interface IBoundingVolume {
public void calculateBounds(Geometry3D geometry);
public void drawBoundingVolume(Camera camera, float[] projMatrix, float[] vMatrix, float[] mMatrix);
public void transform(float[] matrix);
public boolean intersectsWith(IBoundingVolume boundingVolume);
public BaseObject3D getVisual();
}
最佳答案
super()
是指扩展的class
(不是已实现的接口(interface))。在这种情况下是Object
因此它将在Object
中调用构造函数(不执行任何操作)
关于java - 构造函数中的super(),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15206890/