I'm trying to find the minimum and the maximum of a
ArrayList<Entry>
For example my ArrayList looks like this:
ArrayList<Entry> test = new ArrayList<Entry>();
test.add(new Entry(20, 0));
test.add(new Entry(5, 0));
test.add(new Entry(15, 0));
now I want the minimum(5) and the maximum(20) of this list.
I tried it with:
Collections.min(test);
But it says:
Bound mismatch: The generic method min(Collection<? extends T>) of type Collections is not applicable for the arguments (ArrayList<Entry>). The inferred type Entry is not a valid substitute for the bounded parameter <T extends Object & Comparable<? super T>>
I also tried:
test.length()
so I could do a for loop. But it also failed with this kind of ArrayList.
test.size()instead oftest.length(). And don't hesitate to read docs