The following program demonstrates how to Find the Largest Number in a Two Dimensional Array in Java.

In this program the 3 X 3 array is created by taking the command line arguments as input. So, if the user doesn’t provide exactly three integer numbers, the program displays an error message and exits. However, if the user specifies nine numbers in the command line, it creates the desired array. After that, a nested for loop finds the largest of these nine numbers.

``````public class Exercise14
{
public static void main(String[] args) {
if(args.length!=9)
{
System.exit(0);
}
int[][] arr=new int;
int c=0;
int biggest;
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
arr[i][j]=Integer.parseInt(args[c]);
c++;
}
}
biggest=arr;
System.out.println("Original Array...");
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
System.out.print(arr[i][j]+" ");
}
System.out.println();
}
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
if(biggest<arr[i][j]) biggest=arr[i][j];
}
}
System.out.println("The biggest number in the given array is "+biggest);
}
}``````

Output