Skip to content

Instantly share code, notes, and snippets.

@arinto
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arinto/9994221 to your computer and use it in GitHub Desktop.
Save arinto/9994221 to your computer and use it in GitHub Desktop.
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