1.删除map.keySet()集合数据导致map对应数据被删除
Map map = new HashMap();
map.put(1,1);
map.put(2,2);
map.put(3,3);
Map map1 = new HashMap();
map1.put(1,1);
map1.put(2,2);
Set set = map.keySet();
set.removeAll(map1.keySet());
System.out.println(map);
//结果map中只有(3,3)
2.利用java8的stream
Map<Long, XXXObject> id2itemInfos = xxxService.listByIds(tempIds)
.stream()
.collect(Collectors.toMap(XXXObject::getxxxId, x -> x, (k1, k2) -> k1));
由于XXXObject.getxxxId()不唯一,导致数据丢失
3.判断Long类型是否为0
错误写法:
public static void main(String[] args) {
Long id = 1L;
System.out.println(id.equals(1));
}
//结果为false