Please reply to this as soon as possible, please.
My method is as follows:
But when I enter the input as {1,2,3 .......} it shows:Quote:
public void main (int a[][])
Error: incompatible types - found int but expected int []
What does this mean?
Printable View
Please reply to this as soon as possible, please.
My method is as follows:
But when I enter the input as {1,2,3 .......} it shows:Quote:
public void main (int a[][])
Error: incompatible types - found int but expected int []
What does this mean?
In the method you need two dimensional array. But your arguments are just an int values. That's why compiler complain it.
I'm sorry I didn't get you. Isn't that how you enter data for a two dimensional array as well, within curly brackets?
(PS: I apologize at my ignorance, this is my first attempt with Arrays)
No, defining a 2D array is as follows.
Basically what we called is that 2D array is an array of arrays. That's mean each array element holds another array.Code:int temp[][] = new int[3][3];
like this,
Is that clear?Code:temp[0] = {1, 2, 3};
temp[1] = {10, 20, 30};
temp[2] = {100, 200, 300};
Or do it all in the declare/define statement:
int[][] twoDim = new int[][] {{1, 3}, {3, 5,7}};
Yep, define an array in anonymous way as Norm mentioned. In that way no need to give the size of the array in declaration.