// 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