當我嘗試將參數傳遞給構造函數時,爲什麼會出現紅色下劃線錯誤,即創建對象?我究竟做錯了什麼?傳遞給構造函數時出錯
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 [] [] {{。 ..},{...},{...}}' –