Article 3: Queue interface and its sub-interfaces and sub-implementations (sub-interface Deque, sub-implementation ArrayDeque, sub-interface BlockingQueue) (0311)

Insert picture description here

1.1Queue interface

Overview

Collection的一个队列子接口
描述的是一个队列
有序(线性表),要求子实现不允许存储null,允许重复元素
注:LinkList主要作为List接口的子实现,不在上述描述的范围内

在queue中出队列操作poll这个方法,如果没有元素可以出队列了,他不是抛出异常,而是返回一个null来标记
所以不能存储null,如果能存储,就有歧义

boolean add(E e)
inserts the specified element into this queue (if it is immediately feasible and does not violate the capacity limit), returns true on success, and throws IllegalStateException if there is currently no available space.

booleanadd (E e)

1.2 Dectue

1.3 ArrayDeque

1.4 BlockingQueue

Guess you like

Origin blog.csdn.net/AC_872767407/article/details/114664402