您的位置:首页 > 编程语言 > Java开发

test7.6

2015-09-25 14:09 417 查看
我试着我BoardGame构造器中的super(i)放在print("BoardGame constructor0")后边。编译器提示错误

Description Resource
Path Location
Type

Constructor call must be the first statement in a constructor
Chess.java /Test7.6/src
line 4 Java Problem

Implicit super constructor Game() is undefined. Must explicitly invoke another constructor
Chess.java /Test7.6/src
line 4 Java Problem

class Game

{Game(int i){System.out.println("Game constructor");}}

class BoardGame extends Game

{BoardGame(int i){System.out.println("BoardGame constructor");super(i);}}

public class Chess extends BoardGame{

Chess(){super(12);System.out.println("Chess constructor");}
public static void main(String[] args) {
Chess x=new Chess();
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Java