Java8里的HashMap对象lambda遍历方法
Posted 梦幻朵颜 Joyce Zhu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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.
以上是关于Java8里的HashMap对象lambda遍历方法的主要内容,如果未能解决你的问题,请参考以下文章