import java.util.*;
import java.util.function.*;
class Person{
	String firstName;
	String lastName;
	int age;
	Person(String f, String l, int a){ firstName = f; lastName = l; age = a; } 
	public String toString(){ return firstName +" "+lastName+", "+age; }
}
class Test{
	static Person findBest(Person [] p, BiPredicate<Person,Person> c){
		Person res = p[0];
		for(int i=1; i<p.length; i++)
			if(!c.test(res,p[i])) res = p[i];
		return res;
	}
	static void test(){
		Person [] p = new Person[4];
		p[0] = new Person("Abe","Lincoln",56);
		p[1] = new Person("John","Kennedy",32);
		p[2] = new Person("George","Washongton",44);
		p[3] = new Person("Franklin","Roosevelt",61);
		System.out.println("Oldest person is:"+ findBest(p,(x,y)->(x.age>y.age)));
		System.out.println("First by last name is:"+ findBest(p,(x,y)->(x.lastName.compareTo(y.lastName)<0)));
		System.out.println("First by first name is:"+ findBest(p,(x,y)->(x.firstName.compareTo(y.firstName)<0)));
	}
	public static void main(String[] args){
		test();
	}
}
