java - Error while passing to the constructor -
why getting red underline error when try pass arguments constructor, i.e. create object? doing wrong?
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; }
im doint somthing wrong writing arguments char[][]
.
i'm assuming method rotatecw , fields declared in class.
when defining 2-d array, array read array of array. in 1d array, use {entry,entry}. in 2d array, {{entry,entry},{entry,entry}}. also, array object , must constructed so.
your problem don't have array constructor , there aren't commas between arrays... array should defined as:
new char[][]{ {'x','.','.'}, {'.','.','x'}, {'x','.','x'}}
and rest of arguments usual.
Comments
Post a Comment