Deque inherits from Queue. In fact, just think that List does not inherit from Queue. It is true that List can easily use remove(Object o) to implement Queue's remove(), but it is generally not designed this way because their meanings are different. Whether to use List to implement Queue is left to the specific class to decide. The answer for LinkedList is yes, and for ArrayList it is no.
As for why ArrayList did not implement Queue, this is because ArrayList itself is just a List covered in Array skin. It is not recommended to insert new data from the top, otherwise the efficiency will be extremely poor. .
ArrayDeque is a textbook deque implementation, and its existence is not controversial.
Deque
inherits fromQueue
. In fact, just think thatList
does not inherit fromQueue
. It is true thatList
can easily useremove(Object o)
to implementQueue
'sremove()
, but it is generally not designed this way because their meanings are different. Whether to useList
to implementQueue
is left to the specific class to decide. The answer forLinkedList
is yes, and forArrayList
it is no.As for why
ArrayList
did not implementQueue
, this is becauseArrayList
itself is just aList
covered inArray
skin. It is not recommended to insert new data from the top, otherwise the efficiency will be extremely poor. .ArrayDeque
is a textbook deque implementation, and its existence is not controversial.