I do have an ArrayList with numbers and I need to get the greatest of them. I thought this would actually solve the problem, but it doesn't for negative numbers since greatest equals 0... Any help?
public static int greatest(ArrayList<Integer> list) {
int greatest = 0;
for (int k : list)
greatest = Math.max(k, greatest);
return greatest;