I just started programming java, and I'm new to English please try to understand my sentence.
I tried to add a fifth number inside the the array. The for loop is not reading number 99 inside the array. I don't want table.length then add one , i want to add as many number as i want in the array and without change the for loop. Is there a code to find how many numbers are in a box(the first array box)?
int[][] table = { { 12, 0, 0, 0 ,99}, { 0, 0, 0, 0, 99}, { 0, 0, 0, 0, 99} };
int max = Integer.MIN_VALUE;
for (int i = 0; i < table.length; i++) {
for (int k = 0; k <= table.length; k++) {
if (table[i][k] >= max) {
max = table[i][k];
}
}
}
System.out.println(max);
int min = Integer.MAX_VALUE;
for (int i = 0; i < table.length; i++) {
for (int k = 0; k <= table.length; k++) {
if (table[i][k] <= min) {
min = table[i][k];
}
}
}
System.out.println(min);