I am trying to make a program that will take an n x n matrix(2-dimensional array of size n) and multiply it by another n x n matrix(2 dimensional array of the same size). I need to do this without using the predefined method for multiplying matrices. To do this for a 2 x 2 array would be simple however my confusion is caused by figuring out how to do the multiplication for all n x n matrices. Here is the code I have written so far.

import java.util.*;
class matrixX
{
public static void main (String args[])
{
int n=0;
Scanner scan = new Scanner(System.in);
System.out.println("The array will be n x n. What do you want n to be?");
n=scan.nextInt();
while (n<2)
{
System.out.println("Error: Value not greater than 2. Try Again: ");
n=scan.nextInt();
}
int[][] number1 = new int[n][n];
for (int i=0; i<number1.length; i++)
{
for (int j=0; j<number1[i].length; j++)
{
number1[i][j]= (int) ( 0 + Math.random() *10);
System.out.print(number1[i][j]+" ");
}
System.out.println(" ");
}
System.out.println();
int[][] number2 = new int[n][n];
for (int i=0; i<number2.length; i++)
{
for (int j=0; j<number2[i].length; j++)
{
number2[i][j]= (int) ( 0 + Math.random() *10);
System.out.print(number2[i][j]+" ");
}
System.out.println(" ");
}

}
}