我正在尝试在构造函数中使用 2 个输入参数创建一个二维字符数组。 当我尝试创建数组时收到此错误:
The type of the expression must be an array type but it resolved to Class<Character>
.
这是我创建这个动态数组的尝试:
public class Screen {
int Width;
int Height;
char[][] Display;
String lightness = "@BR*#$PX0woIcv:+!~.,";
Screen(int Width, int Height) {
this.Width = Width;
this.Height = Height;
Display = char[Width][Height];
}
//rest of the methods...
}
第 9 行缺少
new
,这不是定义 Display
变量的方法。
Display = char[Width][Height];