1.
2.
package com.gang; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; public class Harbor01 { public static void main(String[] args) throws InterruptedException, ParseException { ArrayList<Student> list = new ArrayList<>(); list.add(new Student("张三",16)); list.add(new Student("张四",19)); list.add(new Student("李五",15)); list.add(new Student("张马六",16)); System.out.println(makeList(list)); } public static List<Map<String,Object>> makeList(List<Student> list){ List<Map<String,Object>> list1=new ArrayList<>(); for (Student student : list) { Map<String, Object> map = new HashMap<>(); map.put("name",student.getName()); map.put("age",student.getAge()); list1.add(map); } return list1; } }