构造函数中的 super() [英] super() in constructor

查看:24
本文介绍了构造函数中的 super()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读一些代码.在构造函数中它有 super() 但该类实现了接口,当然它没有构造函数.那么它指的是哪个 super() 呢?

I'm reading through some code. In the constructor it has super() but the class implements interface which of course doesn't have a constructor. So which super() it is referring to?

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(不是已实现的接口).在这种情况下是 Object

super() refers to the extended class (not an implemented interface). Which in this case is Object

所以它会调用Object中的构造函数(什么都不做)

So it will call the constructor in Object (Which does nothing)

这篇关于构造函数中的 super()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆