java运行时报 super constructor GameObject() is undefined. Must explicitly invoke another constructor的错误

话不多说,上代码:

package com.dyy.game;

import java.awt.Graphics;
import java.awt.Image;

public class Plane extends GameObject{
	public void drawSelf(Graphics g) {
		g.drawImage(img,(int)x,(int)y,null);
		x++;
	}
	
	public Plane(Image img,double x,double y){
		this.img = img;
		this.x = x;
		this.y = y;
		// TODO Auto-generated constructor stub
	}

}

这里public plane这行报错,具体情况是这样:

然后我看了下论坛里面大家的解决办法:

在构造方法第一行加入super(),然后就好了。虽然不是什么大错误,但是值得警示:

构造方法中super()必须写在第一行!

猜你喜欢

转载自blog.csdn.net/dyy0920/article/details/83718325