I have an ArrayList of a class object like below:
ArrayList<Score> scoreboard = new ArrayList<>();
The Score class has a field points:
class Score {
private int points;
//constructor and methods
}
How would i go about using Java streams to compare the points in each of this Score object and return the object with the highest/lowest value?
I tried something like this but it did not work:
scoreboard
.stream()
.max(Comparator.comparing(Score::getPoints)
.get()
.forEach(System::println);