i looked around a bit here on the site but found nothing that seemed to help me on this problem.
so here's my little issue. lets say i have a function that looks like this
public static void main(String args[])
{
int[][] array = new int[9][9];
createArray(array);
}
and i'm trying to pass array into this method so that i can initialize it with input that was read from the console.
public static void createArray(int[][] array)
{
Scanner input = new Scanner(System.in);
int i = 0;
int j = 0;
for(i = 0; i < 9; i++)
{
for(j = 0; j < 9; j++)
{
array[i][j] = input.nextInt();
}
}
input.close();
}
i would think that this would work, since java passes arrays by reference so that means that the createArray() method is receiving the memory address of the array back in main, and therefore any changes here affects the original one in main.
but for some reason that i'm not seeing, running this gives me these errors, and i dont understand what i'm doing wrong