Lambda用到了JDK8自带的一个函数式接口Comparator<T>. 准备一个Apple类 public class Apple { private int weight; private String color; public Apple(){} public Apple(int weight) { this.weight = weight; } public Apple(int weight, String color) { this.weight = weight; this.c
//定义一个100元素的集合,包含A-Z List<String> list = new LinkedList<>(); for (int i =0;i<100;i++){ list.add(String.valueOf((char)('A'+Math.random()*('Z'-'A'+1)))); } System.out.println(list); //统计集合重复元素出现次数,并且去重返回hashmap Map<String, Long> map = l