I know Hashtable doesn't allow null values as it was legacy, which was fixed by HashMap. Null is not allowed in a tree as sorting would be an issue. But why us null not allowed in ArrayDeque?
From the Javadoc for
Dequeimplementations are not strictly required to prohibit the insertion of null elements, they are strongly encouraged to do so. Users of any
Dequeimplementations that do allow null elements are strongly encouraged not to take advantage of the ability to insert nulls. This is so because
nullis used as a special return value by various methods to indicated that the deque is empty.
ArrayDeque implementation also uses
null to indicate an empty element (as explained in sestus' and Aman jangra's answers), so the reasoning is two-fold: contract and implementation details.
It's worth noting that it
ArrayDeque could easily support null elements without much additional complexity, so the more compelling reason seems to be the suggestion of the