java 集合对象

Java 基础之集合_java集合继承关系图-优快云博客

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值