collections

Mapping a list to Map Java 8 stream and groupingBy

不羁岁月 提交于 2020-11-27 04:56:35
问题 I have this simple Bean class: public class Book { public Book(Map<String, String> attribute) { super(); this.attribute = attribute; } //key is isbn, val is author private Map<String, String> attribute; public Map<String, String> getAttribute() { return attribute; } public void setAttribute(Map<String, String> attribute) { this.attribute = attribute; } } In my main class, I have added some information to the List: Map<String, String> book1Details = new HashMap<String, String>(); book1Details

Mapping a list to Map Java 8 stream and groupingBy

岁酱吖の 提交于 2020-11-27 04:56:31
问题 I have this simple Bean class: public class Book { public Book(Map<String, String> attribute) { super(); this.attribute = attribute; } //key is isbn, val is author private Map<String, String> attribute; public Map<String, String> getAttribute() { return attribute; } public void setAttribute(Map<String, String> attribute) { this.attribute = attribute; } } In my main class, I have added some information to the List: Map<String, String> book1Details = new HashMap<String, String>(); book1Details