gistfile1.txt List persons = Arrays.asList(new Person("Joe", 12), new Person("Jim", 34), new Person("John", 23)); persons.sort((p1,p2) - p1.getName().compareTo(p2.getName())); persons.forEach(p - System.out.println(p.getName()));
Listpersons = Arrays.asList(new Person("Joe", 12), new Person("Jim", 34), new Person("John", 23)); persons.sort((p1,p2) -> p1.getName().compareTo(p2.getName())); persons.forEach(p -> System.out.println(p.getName()));