Skip to content

Instantly share code, notes, and snippets.

@tomwhoiscontrary
Created August 16, 2017 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomwhoiscontrary/c750b4ef31b7217892779e0f8747691a to your computer and use it in GitHub Desktop.
Save tomwhoiscontrary/c750b4ef31b7217892779e0f8747691a to your computer and use it in GitHub Desktop.
IntelliJ inference bug
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.stream.Collectors;
public class IntelliJInferenceBug {
public static void main(String[] args) {
Map<String, Integer> map = new HashMap<>();
map.put("one", 1);
map.put("two", 2);
map.put("three", 3);
map.put("four", 4);
System.out.println(map);
SortedMap<String, Integer> sortedMap = map.entrySet().stream()
.collect(Collectors.toMap(e -> e.getKey(),
Map.Entry::getValue,
(u, v) -> u,
TreeMap::new));
System.out.println(sortedMap);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment