/**
* 获取前后更改后的相同key值
* @param map
* @param mapbefore
* @return
*/
public static Map<String, Object> mapDifferent(Map<String, Object> map, Map<String, Object>mapbefore){
Map<String, Object> mapbeforeAll = new HashMap<>();
// 获取前后更改后的相同key值
if (!CommonUtils.isEmpty(map)) {
for (String key1 : map.keySet()) {
if (!CommonUtils.isEmpty(map.get(key1)) && !CommonUtils.isEmpty(mapbefore.get(key1))) {
String map1value = map.get(key1).toString();
String map2value = mapbefore.get(key1).toString();
if (!map1value.equals(map2value)) {
mapbeforeAll.put(key1, map2value);
}
}
}
}
return mapbeforeAll;
}
java比较两个map获取相同key值
最新推荐文章于 2023-08-07 19:32:20 发布