SET
hashset类需要重写equals和hashcode来保证插入自定义类的唯一性。
hashset的add方法利用了HashMap的putval方法。
treeset有自然排序和定制排序,其add方法利用了treemap的put方法。
treeset和treemap不需要重写equals和hashcode方法。
treeset利用重写后的compare方法(如果是自然排序的话)保持元素唯一性。
MAP
hashmap需要重写equals和hashcode来保证插入自定义类作为key的唯一性。
treemap同treeset。