peekFirst
peekFirst is a method of the Deque interface in Java that retrieves, without removing, the element at the front of the deque. It returns the first element or null if the deque is empty, and it does not modify the deque’s contents. This method supports double-ended queue semantics by allowing inspection of the head without dequeuing it.
A key point is how nulls are handled. In implementations that disallow null elements (such as ArrayDeque),
Related methods include peekLast, which retrieves the last element without removing it, and getFirst, which also
Common implementations of Deque that provide peekFirst include ArrayDeque and LinkedList. ArrayDeque is often preferred for