@@ -0,0 +1,1474 @@
+package com.yxy.chukonu.java.jdk18.feature.lambda.expr;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Collections;%0Aimport java.util.Comparator;%0Aimport java.util.List;%0A%0Apublic class SortTest %7B%0A%09%0A%09public static void main(String%5B%5D args) %7B%0A%09%09%0A%09%09//Old method%0A%09%09List%3CString%3E list = Arrays.asList(%22A%22, %22C%22, %22E%22, %22D%22);%0A%09%09Collections.sort(list, new Comparator%3CString%3E() %7B%0A%09%09    @Override%0A%09%09    public int compare(String a, String b) %7B%0A%09%09        return b.compareTo(a);%0A%09%09    %7D%0A%09%09%7D);%0A%09%09%0A%09%09for(String item : list)%7B%0A%09%09%09System.out.print(item+%22 %22) ;%0A%09%09%7D%0A%09%09%0A%09%09System.out.println() ;%0A%09%09%0A%09%09//JDK1.8 new feature - Lambda (1)%0A%09%09List%3CString%3E list2 = Arrays.asList(%22A%22, %22C%22, %22E%22, %22D%22);%0A%09%09Collections.sort(list2, (String a, String b) -%3E %7B%0A%09%09    return b.compareTo(a);%0A%09%09%7D);%0A%09%09%0A%09%09for(String item : list2)%7B%0A%09%09%09System.out.print(item+%22 %22) ;%0A%09%09%7D%0A%09%09%0A%09%09System.out.println() ;%0A%09%09%0A%09%09//JDK1.8 new feature - Lambda (2)%0A%09%09List%3CString%3E list3 = Arrays.asList(%22A%22, %22C%22, %22E%22, %22D%22);%0A%09%09Collections.sort(list3, (String a, String b) -%3E b.compareTo(a));%0A%09%09%0A%09%09for(String item : list3)%7B%0A%09%09%09System.out.print(item+%22 %22) ;%0A%09%09%7D%0A%09%09%0A%09%09System.out.println() ;%0A%09%09%0A%09%09//JDK1.8 new feature - Lambda (3)%0A%09%09List%3CString%3E list4 = Arrays.asList(%22A%22, %22C%22, %22E%22, %22D%22);%0A%09%09//If there is only one line in method body, %22%7B%7D%22 and %22return%22 keywords could be omitted.%0A%09%09//args data types could be inferred automatically.%0A%09%09Collections.sort(list4, (a, b) -%3E b.compareTo(a));%0A%09%09%0A%09%09for(String item : list4)%7B%0A%09%09%09System.out.print(item+%22 %22) ;%0A%09%09%7D%0A%09%09%09%09%0A%09%7D%0A%0A%7D%0A

add example for JDK1.8 new feature - Lambda expression