Map<String, Item> map =
list.stream().collect(Collectors.toMap(Item::getKey, item -> item));
Map<String,Set<String>> map = list.stream().
collect(Collectors.groupingBy(
Student::getName,
Collectors.mapping(e->getNum(e.getAddr()), Collectors.toSet())
));
System.out.println("Map : "+map);
// convert List<Elem> into a Map<Elem::getName, Elem:getId>
Map<String, String> myMap = elemsList.stream()
.collect(Collectors.toMap(elem -> elem.getName(), elem -> elem.getId()));
// you may pay attention of elem null cases