【发布时间】:2014-05-03 14:12:19
【问题描述】:
我有两张地图:
Map<String, Sample> newMap = convertJSONObjectToSampleMap(newMapStr);
Map<String, Sample> oldMap = convertJSONObjectToSampleMap(oldMapStr);
Sample 是一些自定义类
newMap 有键:[1,2,3,4,5]
oldMap 有键:[2,3,4,5,8]
获得它们之间差异的最佳方法是什么,例如,使用密钥获取Samples:1 和8?
我想使用Collections 并提取Set<>:
Set<String> newSet = newMap.keySet();
Set<String> oldSet = oldMap.keySet();
谢谢你,
【问题讨论】:
标签: java collections map set-difference