Location>code7788 >text

List> Properties

Popularity:437 ℃/2024-10-28 11:50:37
public static void main(String[] args) { // 1. Data preparation List<Map<String,Object>> list = new ArrayList<>(); Map<String,Object> map = new HashMap<>(); ("name", "songwp"); ("age", 25); ("gender", "male"); Map<String,Object> map1 = new HashMap<>(); ("name", "zhangsan"); ("age", 26); ("gender", "men"); Map<String,Object> map2 = new HashMap<>(); ("name", "lisi"); ("age", 24); ("gender", "male"); (map); (map1); (map2); ("Raw data:" +list); // 2. According to the name into Map Map<Object, Map<String, Object>> resultMap = ().collect((m -> ("name"), m -> m)); ("Result of conversion to Map based on name:" +resultMap); // 3. According to the name into a List List<Object> names = ().map(m -> ("name")).collect(()); ("The result of converting to a List based on name; "+names); }