a) int i[] = new int[2]{1,2}; b) int[] i = new int[]{1,2,3}{4,5,6};
I know we cannot give size of an array at declaration . But in statement(a) we
Both are illegal!
a) You either specify the size or the content. Legal would be:
int i[] = new int[2]; i[0] = 1; i[1] = 2;
or
int i[] = new int[]{1,2};
b) 2-dimensional arrays are arrays containing arrays. So, you have to write:
int[] i = new int[][]{{1,2,3}, {4,5,6}}; ^ ^ ^