Tag: collections
-
Understanding Comparable and Comparator - with examples
The compareTo() contracts, the overflow trap, consistency with equals, and choosing between Comparable and Comparator - with code examples and interview questions.
-
What hides behind the (31 * x + y) formula in hashCode()?
Why Java picked 31 for hashCode(), what breaks without the multiplier, and how HashMap compensates for the formula on its own side.