Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
finding the smartest student without lambda
public class FindMaxNoLambda {
public static void main(String[] args) {
Set<Student> aSetOfStudents = initStudents();
double maxGrade = Double.MIN_VALUE;
Student smartestStudent;
for(Student s: aSetOfStudents) {
if(2014 == s.getGraduationYear() && s.getGrade() > maxGrade) {
smartestStudent = s;
maxGrade = s.getGrade()
System.out.printf("Max grade: %s%n", maxGrade);
private static Set<Student> initStudents() {
//initialize a set of Student
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment