Java8里的HashMap对象lambda遍历方法
Java demo:
Map<String, User> map = new HashMap<>(); map.put("id1", new User(1,"name1")); map.put("id2", new User(2,"name2")); String str = map.entrySet().stream().map(entry -> "id[" + entry.getKey() + "], code=" + entry.getValue().getCode() + ", text=" + entry.getValue().getText() ).collect(Collectors.joining("; ")); System.out.println("str==="+str);
end.