Hey, I'm a newbie to java and am getting a syntax error on my passing of the array in the main method. It does not like that I am passing Num3, Num4. Since its an array do I have to pass it a certain way? Any insight would be helpful, Thanks in advance!
Here is the coding I have in the method:
public static int intArray(int [][] myArray){
int[][] intArray = new int[2][10];
for (int r = 0; r<myArray.length; r++){
for (int c = 0; c<myArray[r].length; c++){
myArray[r][c] = r++;
}//close 2nd for
}//close 1st for
}//close myArray method
Here is the coding I have in the main:
else if (commandtoken.equalsIgnoreCase("NUM")){
int Num3 = Integer.parseInt(st.nextToken());
int Num4 = Integer.parseInt(st.nextToken());
int[][] myArray = new int[Num3][Num4];
System.out.println("Number Array with " + Num3 + " rows and " + Num4 + " columns " + intArray(Num3, Num4));
This is the error I am receiving:
Assign1.java [49:1] intArray(int[][]) in Assign1 cannot be applied to (int,int)
Num4 + " columns " + intArray(Num3, Num4));
^
1 error
Errors compiling main.
Here is the coding I have in the method:
public static int intArray(int [][] myArray){
int[][] intArray = new int[2][10];
for (int r = 0; r<myArray.length; r++){
for (int c = 0; c<myArray[r].length; c++){
myArray[r][c] = r++;
}//close 2nd for
}//close 1st for
}//close myArray method
Here is the coding I have in the main:
else if (commandtoken.equalsIgnoreCase("NUM")){
int Num3 = Integer.parseInt(st.nextToken());
int Num4 = Integer.parseInt(st.nextToken());
int[][] myArray = new int[Num3][Num4];
System.out.println("Number Array with " + Num3 + " rows and " + Num4 + " columns " + intArray(Num3, Num4));
This is the error I am receiving:
Assign1.java [49:1] intArray(int[][]) in Assign1 cannot be applied to (int,int)
Num4 + " columns " + intArray(Num3, Num4));
^
1 error
Errors compiling main.