此类实现 Set 接口,由哈希表(实际上是一个 HashMap 实例)支持.它不保证 set 的迭代顺序:特别是它不保证该顺序恒久不变.此类允许使用 null 元素. HashSet<String> set = new HashSet<String>();set.add("abc"); private transient HashMap<E,Object> map; /** * Constructs a new, empty set; the bac…
在对List.Set.Map执行遍历删除或添加等改变集合个数的操作时,不能使用普通的while.for循环或增强for.会抛出ConcurrentModificationException异常或者没有达到删除的需求.在遍历时删除元素,需要使用迭代器的方式. ArrayList源码中说明的报异常原因: * <p>The iterators returned by this class's <tt>iterator</tt> and * <tt>listIte…