Must explicitly invoke another constructor

后端 未结 6 1051
借酒劲吻你
借酒劲吻你 2021-01-25 03:27

Why is Eclipse keeps giving me error on the constructor:

 public DenseBoard(Tile t[][]){
      Board myBoard = new DenseBoard(t.length, t[0].length);
  }
         


        
6条回答
  •  伪装坚强ぢ
    2021-01-25 04:06

    In your class Board you only have one constructor which requires 2 int arguments.

    And since DenseBoard extends Board, each of the constructor in DenseBoard should call some constructor in Board.

    If Board had a no-arg constructor, the compiler would automatically call it for you. But since you don't have one, you should call another constructor explicitly from your public DenseBoard(Tile t[][]).

提交回复
热议问题