当我尝试将参数传递给构造函数时,为什么会出现红色下划线错误,即创建对象?我究竟做错了什么?传递给构造函数时出错
public static void main(String[] args)
{
CreateShape temp = new CreateShape(3,3, 'a',
{{'x','.','.'}
{'.','.','x'}
{'x','.','x'}}, "x . .\n"
+ ". . x\n"
+ "x . x");
temp.rotateCW();
System.out.println(temp);
public CreateShape(int height, int width, char dc, char[][] charLayout, String layout)
{
this.height = height;
this.width = width;
this.dc = dc;
this.shape = charLayout;
this.layout = layout;
initialPos = Rotation.CW0;
}
通过编写参数为char[][]
,我做了一些错误。
缺少逗号行的二维数组 – Alejandro
在分开......还缺少'新的char [] []'部分:'新的char [] [] {{。 ..},{...},{...}}' –