JAVA合并两个具有相同key的map为list,不多说,直接上代码:
/**
* list合并类
*/
public class MapUtil {
public static void main(String[] args){
List> osvList = new ArrayList<>();
Map map1 = new HashMap<>();
map1.put("osV","5.1");
map1.put("gaidNum","100");
Map map2 = new HashMap<>();
map2.put("osV","4.4.2");
map2.put("gaidNum","150");
osvList.add(map1);
osvList.add(map2);
List> ipList = new ArrayList<>();
Map map3 = new HashMap<>();
map3.put("osV","5.1");
map3.put("ipNum","200");
Map map4 = new HashMap<>();
map4.put("osV","4.4.2");
map4.put("ipNum","300");
ipList.a