public static List<Student> getStudents(List<Student> students) {
return students.stream(). // rest of the code comes here.
}
I'd like to return a List<Student>
which contains the students sorted in a descending order by their averages. I have to use lambda expression with the stream()
method.
Example class:
public class Student {
private String name;
private int birthYear;
private double average;
public Student(String name, int birthYear, double average) {
this.name = name;
this.birthYear = birthYear;
this.average = average;
}
...getters and setters...
}