The Deque.remove()
method is used to remove the head element from a deque. The Deque.remove()
method is present in the Deque
interface inside the java.util
package.
Deque.element remove()
The Deque.remove()
method doesn’t take any parameters.
The Deque.remove()
method returns the element present at the head of the deque, which is being removed.
Let’s take a look at the code snippet below.
import java.util.*;class Main{public static void main(String[] args){Deque<Integer> d = new LinkedList<Integer>();d.add(212);d.add(23);d.add(621);d.add(1280);d.add(3121);d.add(18297);d.add(791);System.out.println("Elements of the deque are: " +d);d.remove();System.out.println("Elements in the deque are: "+d);}}
Main
class.main
function.Integer
type elements.Deque.add()
method.remove()
method.In this way, we can use Deque.remove()
method in Java.