Created
August 16, 2017 14:42
-
-
Save tomwhoiscontrary/c750b4ef31b7217892779e0f8747691a to your computer and use it in GitHub Desktop.
IntelliJ inference bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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