@@ -0,0 +1,1203 @@
+public class Java8Way %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09%0A%09%09java.util.List%3CPerson%3E list = java.util.Arrays.asList(%0A%09%09%09%09new Person(%22Amit%22, %22Upadhyay%22, 20),%0A%09%09%09%09new Person(%22Katrina%22, %22Kaif%22, 21),%0A%09%09%09%09new Person(%22Deepika%22, %22Padukone%22, 22),%0A%09%09%09%09new Person(%22Naina%22, %22Bhatiya%22, 19),%0A%09%09%09%09new Person(%22Sonal%22, %22Peru%22, 19)%0A%09%09%09%09);%0A%09%09%0A%09%09// step1: sort according to last name%0A%09%09java.util.Collections.sort(list, (Person o1, Person o2) -%3E o1.getLastName().compareTo(o2.getLastName()));%0A%09%09%0A%09%09// step2: print them%0A%09%09System.out.println(%22Printing all names%22);%0A%09%09System.out.println();%0A%09%09printLists(list);%0A%0A%09%09// step3: print people who have last name beginning with P%0A%09%09System.out.println();%0A%09%09System.out.println(%22Printing names whose first character of last name is P%22);%0A%09%09System.out.println();%0A%09%09printConditionally(list, p -%3E p.getLastName().startsWith(%22P%22));%0A%09%7D%0A%0A%09private static void printConditionally(java.util.List%3CPerson%3E list, Condition c) %7B%0A%09%09for (Person p: list)%0A%09%09%09if (c.test(p))%0A%09%09%09%7B%0A%09%09%09%09System.out.println(p);%0A%09%09%09%7D%0A%09%7D%0A%0A%09private static void printLists(java.util.List%3CPerson%3E list) %7B%0A%09%09for (Person p: list)%0A%09%09%09System.out.println(p);// this will call the toString method defined in Person class.%09%0A%09%7D%0A%7D%0A

Create Java8Way.java