2.
3.
package com.itheima.demo18_扩展字符串排序; import java.util.*; import java.util.stream.Collectors; public class Harbor { public static void main(String[] args) { List<Student> lendReturnList = Arrays.asList(new Student("zd", 101), new Student("zd1", 10), new Student("zd2", 102)); Map<Integer, String> lendReturnMap = lendReturnList.stream().collect( Collectors.toMap(Student::getAge, Student::getName) ); for (Map.Entry<Integer, String> entry : lendReturnMap.entrySet()) { System.out.println(entry.getKey() + entry.getValue()); } } }