判断集合是否有某个指定键,map类型转换为实体类类型
if (getfhxxxx.stream().anyMatch(item -> item.getKey().equals("林地"))) {
System.out.println("集合中包含需要的键值");
} else {
System.out.println("集合中不包含需要的键值");
String addlds = fhService.addld(quyv, code);
HashMap<String, String> map = new HashMap<>();
System.out.println("林地内容" + addlds);
map.put("林地", addlds);
System.out.println("lddldldldldld" + map);
// 将HashMap转换为实体类类型 map是 HashMap<String, String> map = new HashMap<>();
//map->list
for (Map.Entry<String, String> entry : map.entrySet()) {
Fhxinxi fhxinxi = new Fhxinxi();
fhxinxi.setMj(entry.getValue());
fhxinxi.setKey(entry.getKey());
fhxinxi.setCode("03");
getfhxxxx.add(fhxinxi);
}
}
list=>map
for (Map.Entry<Integer, String> entry : map.entrySet()) {
System.out.println("Key: " + entry.getKey() + ", Value: " + entry.getValue());
}