So I'm trying to come up with this method that will display the index of the maximum number in the 2D array. I was able to do it for a single D array, but I'm having trouble doing it for the 2D.
public static int findMaximumValue(int[ ][ ] a)
{
int maxVal = a [0][0];
int i = 0;
for(i = 0; i < a.length; i++)
{
for(int j = 0; j < a[0].length; j++)
{
if(a[i][j] > maxVal)
{
maxVal = a[i][j];
}
}
}
return(maxVal);
}
2D ARRAY
public static int [][] findMaximumIndex(int[ ][ ] a)
{
int maxVal = a[0][0];
int [][] maxIndex = new int [1][2];
int row = 0, col = 0;
for(row = 0; row < a.length; row++)
{
for(col = 0; col < a[row].length; col++)
{
if(a[row][col] > maxVal)
{
maxVal = a[row][col];
maxIndex [1] [2] = a[row][col];
}
}
}
return(maxIndex);
}