Map<String, String> phoneBook = people.stream()
.collect(toMap(Person::getName,
Person::getAddress));
I get java.lang.IllegalStateException: Duplicate key
when a duplicated element is found.
Is it possible to ignore such exception on adding values to the map?
When there is duplicate it simply should continue by ignoring that duplicate key.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…