从此封心@
2021-10-19 18:05
采纳率: 81.3%
浏览 31
已结题

求写下代码,并每行添加注释

/*
请用代码将list2中的score合并到List中(如果匹配不到则用"-"代替)
*/
package test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Exercise {

public static void main(String[] args) {
    List<Map<String,String>> list1=new ArrayList<>();
    List<Map<String,String>> list2=new ArrayList<>();
    Map<String,String>map;

    map=new HashMap<>();
    map.put("id","1");
    map.put("name","张三");
    list1.add(map);

    map=new HashMap<>();
    map.put("id","2");
    map.put("name","李四");
    list1.add(map);

    map=new HashMap<>();
    map.put("id","3");
    map.put("name","王五");
    list1.add(map);

    map=new HashMap<>();
    map.put("id","2");
    map.put("score","90");
    list2.add(map);

    map=new HashMap<>();
    map.put("id","3");
    map.put("score","88");
    list2.add(map);

    map=new HashMap<>();
    map.put("id","4");
    map.put("score","75");
    list2.add(map);

    //todo 从这里开始
}

}

1条回答 默认 最新

相关推荐 更多相似问题