Ejemplo n.º 1
0
 public Student findByName(String name) {
   // for (Student student : students) {
   for (Student student : students.values()) {
     if (student.getName().equals(name)) {
       return student;
     }
   }
   throw new IllegalArgumentException("not found");
 }
Ejemplo n.º 2
0
  public static void main(String[] args) {
    final Student s1 = new Student();
    s1.setName("andre");
    s1.setResult("B");
    final Student s2 = new Student();
    s2.setName("ribeiro");

    School school = new School(Arrays.asList(s2));

    school.addStudent(s1);
    System.out.println("Andre tirou nota: " + school.findByName("andre").getResult());
  }