6、<)o~~)。为了说明HashSet在Java中确实如上实现,下面附上JDK中两个重要方法的源码:(下面源码来自于HashMap,原因是HashSet是基于HashMap实现的)viewplainprint?1./** 1. * Rehashes the contents of this map into a new array with a 2. * larger capacity. This method is called automatically when the 3. * number of keys in this map reaches
7、 its threshold. 4. * 5. * If current capacity is MAXIMUM_CAPACITY, this method does not 6. * resize the map, but sets threshold to Integer.MAX_VALUE. 7. * This has the effect of preventing future calls. 8. * 9. * @param newC