Map<String, String> phoneBook = people.stream()
.collect(toMap(Person::getName,
Person::getAddress));
当发现重复的元素时,我得到java.lang.IllegalStateException: Duplicate key
.
在向 map 添加值时是否可以忽略此类异常?
当存在重复密钥时,只需忽略该重复密钥即可继续.