1. public class Main {
    2. public static void main(String[] args) {
    3. String[] array = new String[] { "Apple", "Orange", "Banana", "Lemon" };
    4. Arrays.sort(array, (s1, s2) -> {
    5. return s1.compareTo(s2);
    6. });
    7. System.out.println(String.join(", ", array));
    8. }
    9. }
    10. // 观察Lambda表达式的写法,它只需要写出方法定义:
    11. (s1, s2) -> {
    12. return s1.compareTo(s2);
    13. }