java基础-集合

分类: Java

图片1.png

List:有序,可重复

ArrayList:主要实现类(List list=Collections.synchronizeList(list);包装成线程同步,安全,性能低)
LinkedList:对于频繁的插入、删除操作
Vector:古老的实现类,线程安全的,不建议使用

Set:无序,不可重复

添加进set中的元素,一定要重写equals和hashCode方法
HashSet:主要实现类,底层由hashmap实现
LinkHashSet:插入性能略低于Hash,迭代访问的时候有很好的性能
TreeSet:向TreeSet添加的元素必须是同一种类型的,默认从小到大排序

图片2.png

Map

Map对象所对应的类,须重写equals和hashCode方法

HashMap:主要实现类Map map=Collections.synchronizeMap(map);包装成线程同步,安全,性能低
LinkedHashMap:使用链表维护Map中的顺序,故遍历时,是按添加进的顺序
TreeMap:按照添加进map中元素的key的指定属性进行排序,key必须是同一个类的对象
HashTable:古老的实现类,线程安全不允许使用null作为key,value,不建议使用

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注


Warning: error_log(/www/wwwroot/codegulu.cn/wp-content/plugins/spider-analyser/#log/log-1020.txt): Failed to open stream: Permission denied in /www/wwwroot/codegulu.cn/wp-content/plugins/spider-analyser/spider.class.php on line 2969