简析hashset的实现原理
hashset底层为hashmap。 源码如下: /** * Constructs a new, empty set; the backing HashMap instance has * default initial capacity (16) and load factor (0.75). */ public HashSet() { map = new HashMap<>(); } 默认 initial capacity(hashmap底层数组大小)为16,load factor 为 0.75 add() 方法 /** * Adds the specified element to this set if it is not already present. * Mo...阅读全文