Retrieves, but does not remove, the head of the queue represented by this deque. This method differs from
peek()
only in that it throws an exception if this deque is empty.
public static void main(String... args) { ArrayDeque<Integer> ad = new ArrayDeque<>(List.of(3, 2, 5, 7)); Integer element = ad.element(); System.out.println(element); element = ad.element(); System.out.println(element); } }