This is the code I have currentlly.
public static void testClosestToMean() {
Scanner input = new Scanner(System.in);
System.out.println("How many rows does your array have: ");
int rows = input.nextInt();
System.out.println("How many columns does your array have: ");
int columns = input.nextInt();
double[][] numbers = new double[rows][columns];
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns; j++)
{
System.out.println("Enter a value for your array: ");
double values = input.nextDouble();
numbers[rows][columns] = values;
}
}
}
When I run my program I reach System.out.println("Enter a value for your array: ");
however when I input a single number and press enter this error occurs:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
I'm just generally stuck and would like guidance or even an explanation of why this error keeps occurring.