java8中谨慎使用实数作为HashMap的key! java8中一个hashCode()函数引发的血案java8中一个hashCode()函数引发的血案1.起因2.实数的hashCode()3.总结1.起因让我关注到这一点的起因是一道题:牛客网上的max-points-on-a-line (如果链接打不开可以直接搜索题目哦) 题目是这么描述的: Given n points on a 2D plane, find the maximum number of points that lie on…
String 对象的不可变性 java8中的String只有2个属性value和hash,相关代码如下: /** The value is used for character storage. */ private final char value[]; /** Cache the hash code for the string */ private int hash; // Default to 0 value是字符串的字符数组,hash是字符串的hash值缓存 public final…