摘要: HashSet<E> 泛型E必须重写hashCode方法,否则会导致add结果与预期不符 如 若不重写hashCode()则输出为2,若重写hashCode()则输出为1。为什么会这样? 查看HashSet的的源码会发现,HashSet的Contains方法,和add方法,其实是引用了HashMap 阅读全文
posted @ 2018-07-24 19:31 annofyf 阅读(652) 评论(0) 推荐(0) 编辑