In the Oracle tutorial about Collection
interfaces, the interface hierarchy suggests that a Deque
directly extends Collection
.
But Deque
extends Queue
(there doesn't seem to be a change in this relationship across Java releases).
Any reason why this is not reflected in the hierarchy picture (e.g. the same way SortedSet
is shown to extend Set
)?
Taken from The Deque Interface - The Java™ Tutorials:
The Deque interface is a richer abstract data type than both Stack and Queue because it implements both stacks and queues at the same time.
You're right, Deque
indeed extends Queue
in Java...
But even though this actual relation exists, I reckon that the point of omitting it it this diagram is that, conceptually, a Deque
could be seen as not only a specialisation of a Queue
.
A Deque
provides you with both the last-in-first-out principle of a Stack
and the first-in-first-out one that a Queue
offers, and representing only the strict actual hierarchy of these classes and interfaces could be misleading.
For example, LinkedList
implements Deque
... and yet, you'd probably never place it under Deque
on a schema explaining the different types of Collections
and the relations between them. :)