My results are correct, but I don't get the last checkpoint. I could rewrite everything in a different style, but first I would like to know why it doesn't work this way. Thanks in advance!
package de.codegym.task.task05.task0532;
import java.io.*;
import java.util.ArrayList;
/*
Aufgabe zu Algorithmen
*/
public class Solution {
public static void main (String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int maximum;
int n;
ArrayList<Integer> l1 = new ArrayList();
while (true) {
n = Integer.parseInt(reader.readLine());
if (n <= 0) ; //continue; or System.exit(0); not working either
else break;
}
for (int count = 0; count < n; count++) {
l1.add(Integer.parseInt(reader.readLine()));
}
maximum = l1.get(0);
for (int a : l1) {
maximum = maximum <= a ? a : maximum;
}
System.out.println(maximum);
}
}