一、list 转 map

List<Student> list= new ArrayList<>();

1、第一种,List<Student> 转化Map<String,String>
Map<String,String> map = list.stream()
.collect(Collectors.toMap(
Student::getName, Student::getAge, (k1, k2) -> k2));

1、第一种,List<Student> 转化Map<String,Student>
Map<String,Student> map = list.stream()
.collect(Collectors.toMap(
Student::getName, student->student, (k1, k2) -> k2));