欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 焦点 > java 集合对象

java 集合对象

2024/12/22 21:43:30 来源:https://blog.csdn.net/lei7143/article/details/144634523  浏览:    关键词:java 集合对象

Java 基础之集合_java集合继承关系图-CSDN博客

集合可以有序或无序,重复或不能重复,空或不能空。

List<> 集合,是有序,允许重复元素,允许空元素

1、ArrayList<>  非线程安全

2、LInkedList<> 非线程安全

Doubly-linked list implementation of the List and Deque interfaces. 

是实现List  和 Deque的双向列表

3、vector 是线程安全的,容量大小可以改变,跟数组一样索引访问

4、栈

Stack<E> extends Vector<E> 

Queue

public interface Queue<E> extends Collection<E> {

public interface Deque<E> extends Queue<E>

A linear collection that supports element insertion and removal at both ends. The name deque is short for "double ended queue" 

ArrayDeque  非线程安全

Null elements are prohibited. This class is likely to be faster than Stack when used as a stack, and faster than LinkedList when used as a queue

Set<>集合元素不能重复,最多允许一个空元素

HashSet<>  非线程安全

this class implements the Set interface, backed by a hash table (actually a HashMap instance). 

TreeSet<> 非线程安全

A NavigableSet implementation based on a TreeMap. The elements are ordered using their natural ordering, or by a Comparator provided at set creation time, depending on which constructor is used.
This implementation provides guaranteed log(n) time cost for the basic operations (add, remove and contains).

Map<>集合

1、HashMap<> 不能保证顺序,key 不能重复,允许空key 和空val

2、TreeMap 可以保证顺序,非线程安全,是排序的map

基于红黑树,时间复杂度log(n)

A Red-Black tree based NavigableMap implementation. The map is sorted according to the natural ordering of its keys, or by a Comparator provided at map creation time, depending on which constructor is used.
This implementation provides guaranteed log(n) time cost for the containsKey, get, put and remove operations. Algorithms are adaptations of those in Cormen, Leiserson, and Rivest's Introduction to Algorithms.

3、Hashtable<> 是线程安全的,不允许空key 和 空val

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com