mylist = [1, 7, 3, 12, 5]
min_value = min(mylist)
max_value = max(mylist)
>>> m = max(a)
>>> [i for i, j in enumerate(a) if j == m]
[9, 12]
public static void main(String[] args) {
Employee em = new Employee("Kiro",33,"Bulgaria"); //Creating objects
Employee em2 = new Employee("Pesho",35,"Bulgaria");
Employee em3 = new Employee("John",39,"UK");
Employee em4 = new Employee("Mike",53,"USA");
Cafe cafe = new Cafe("Malibu",4); //Creating Cafe & add the objects
cafe.addEmployee(em);
cafe.addEmployee(em2);
cafe.addEmployee(em3);
cafe.addEmployee(em4);
System.out.println("The oldest is: " + cafe.getOldestEmployee()); //prints 53
}
}
public int getOldestEmployee(){
int oldest = 0;
if (this.employees.size() > 1){
Optional<Employee> max = this.employees
.stream()
.max(Comparator.comparingInt(Employee::getAge));
oldest = max.get().getAge();
}else if (this.employees.size() == 1){
oldest = this.employees.get(0).getAge();
}
return oldest;
}