Java Deque pop() Method22 Mar 2025 | 2 min read The pop() method of Java Deque interface is used to pop an element from the given stack represented by this deque. We can also say that the above method removes and return the first element of the deque. The above method is similar to removeFirst() method. Syntax:Parameter:NA Return:The above method is used to return the element at the front of the given deque. Throw:NoSuchElementException- If the given deque is empty. Example 1Output: The first fruit which has been removed is : Apple The final deque is given as : Guava Mango Pear Example 2Output: The first number which has been removed is : 67.0 The final deque is given as : 55.0 78.0 77.0 Example 3Output: The first character which has been removed is : a The final deque is given as : b c d Next TopicJava Deque |
Java Deque peek () Method The method of Java Deque Interface is used to retrieve but not to remove the head of the deque. The method may return null if the given deque is empty. Specified by: peek in interface Queue<E> Syntax: E Parameter: NA Return: The above method...
2 min read
Java Deque Method The method of Java Deque Interface returns true if the deque contains the specified element. Specified by: contains in interface Collection<E> Syntax: boolean contains(Object o) Parameter: The above method consists of only one parameter: a.) The element 'o' which is already present in the deque and is tested. Return: The...
2 min read
Java Deque Method The method of Deque interface is used to remove the first occurrence of the given element from the deque. If there is no element in the deque, then it remains unchanged. It may return true if the deque contains the specified...
2 min read
Java Deque Method The method of Java Deque Interface inserts the given element into the queue which is represented by the particular deque. Specified by: offer in interface Queue<E> Syntax: boolean offer(E e) Parameter: The above method requires only one parameter : The element 'e' that needs to be...
2 min read
Java Deque Method The method of Deque interface is used to insert the specified element into the specified queue represented by the deque and returns true upon success and throws an IllegalStateException if there is no current space available. Specified by: add in interface Collection<E> add in...
2 min read
Java Deque Method The method of Java Deque Interface is used to insert the given element in the front of the deque unless and until it violates the capacity restrictions. While using a capacity restricted deque , the above method is used for addFirst(E)...
2 min read
Java Deque Method The method of Java Deque interface is used to retrieve and remove the head of the deque. The method may differ by poll() method only in one case that it throws an exception if the given deque is empty. Specified by: remove in...
3 min read
Java Deque Method The method of Java Deque Interface retrieves but not remove the head of the queue which is represented by the deque. The above method differs from the peek only in one way that it throws an exception only if the deque...
1 min read
Java Deque Method The method of Java Deque Interface is used to retrieve and remove the last element of the deque. The method may return null if the given deque is empty. Syntax: public E Parameter: NA Return: The above method is used to return the tail of the...
2 min read
Java Deque Method The method of Java Deque Interface is used to retrieve and remove the first element of the deque. The method may return null if the given deque is empty. Syntax: public E Parameter: NA Return: The above method is used to return the head of the...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India