Why HashMap uses TreeNode for not Comparable keys?
问题 I know that in Java 8 HashMap was optimized for poorly distributed hashCode . And in cases when threshold was exceeded it rebuilds nodes in bucket from linked list into tree. Also it is stated that this optimization doesn't work for not comparable keys (at leas performance is not improved). In the example below I put not Comparable keys into HashMap import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.stream.IntStream; class Main { public