我有一个具有char []属性的类,但是当我尝试创建它的实例时,出现错误。我的代码是这样的:
班级:
public class Board
{
private char[] priFC;
public Board(char[] priFC){
this.priFC = priFC;
}
...}
主要:
Board Tab = new Board(char[10]);
创建Tab时,我得到了一个无效的表达式术语char
答案 0 :(得分:2)
在Main中,在创建Tablero
实例时,传递char[]
实例而不是char[10]
像
Tablero Tab = new Tablero(new []{'s','t','a','c','k','o','v','e','r','f','l','o','w'});
或
Tablero Tab = new Tablero(new char[10]);
或
char [] charInstance = new char[]{'s','t','a','c','k','o','v','e','r','f','l','o','w'};
Tablero Tab = new Tablero(charInstance);