Hi. This is the first time I am using this forum, so I apologize if I make any mistakes.
I am trying to find the minimum value in a 2d Array using different
numeric types like double, float, long and int. I can find the correct values
for float and double, but not for int and long.
Here is my code for int values:
public class Array
private int [][]Array = {{3,1,8}, {6,2,5}};
private int lowest = 0;
public Array()
for (int row = 0; row < Array.length; row++)
{
lowestRow = Array[0][0];
for (int col = 0; col < Array[row].length; col++)
{
if (Array[row][col] < lowestRow)
{
lowestRow = Array[row][col];
}
}
System.out.println ("Lowest in row " + row + " is: " + lowestRow);
}
What i get is:
lowest in row 0: 1
lowest in row 1: 3
The loop does not consider the second set of brackets...