Advertisement
drSdGdBy

collect max values from map to other map

Jun 26th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.30 KB | None | 0 0
  1. Double max = map.values().stream().max(Comparator.naturalOrder()).get();
  2.             TreeSet<String> result = map.entrySet()
  3.                     .stream()
  4.                     .filter(e -> e.getValue().equals(max))
  5.                     .map(Map.Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement