I'm just a newbie when it comes to programming, and a student. I was tasked to create a 2-D Array of a multiplication table but I seem to get the same error evertime: java.lang.arrayindexoutofboundsexception 10
Pls help.
Heres the code:
public class MulTtable {
// rows and columns are declared as constants
static final int ROWS= 10;
static final int COLUMNS= 10;
// prints the content of the 2-D array
public static void printTable(char mt[][]){
int n=ROWS;
for (int row = 0; row < ROWS; row++){
for (int COLUMNS = 0; COLUMNS < COLUMNS; COLUMNS++){
{
System.out.print(mt[ROWS][COLUMNS] + "\t");
}
System.out.println();
}
}
}
public static void main(String[] args){
int mTable[][]= new int[ROWS][COLUMNS];
for ( int ROWS = 0; ROWS < mTable.length; ROWS++){
for ( int COLUMNS = 0; ROWS < mTable[ROWS].length; COLUMNS++){
if (ROWS<11) // stores integer 1+1 in the first row of the array
mTable[ROWS][COLUMNS] = 1+1;
else
mTable[ROWS][COLUMNS] = (ROWS)* (COLUMNS);
}
}
}
}
Cheers,
Me
Thank you!