Here is my code :
public static void Max(List<List<String>> data) {
data.forEach(d -> String max = Collections.max(Arrays.asList(d.getMax(5))));
}
The result I get:
70
75
76
How can I get only the maximum number?
Here is my code :
public static void Max(List<List<String>> data) {
data.forEach(d -> String max = Collections.max(Arrays.asList(d.getMax(5))));
}
The result I get:
70
75
76
How can I get only the maximum number?
A more simple way:
int max = Integer.MIN_VALUE;
for (int i = 0; i < data.size(); i++) {
for (int j = 0; j < data.get(i).size(); j++) {
max = Integer.max(Integer.parseInt(data.get(i).get(j)), max);
}
}
System.out.println(max);
This way we comb through every member of each list and by invoking max() we get the max number, which is then displayed in the console.