Java Deque.remove(Object o)

Syntax

Deque.remove(Object o) has the following syntax.

boolean remove(Object o)

Example

In the following code shows how to use Deque.remove(Object o) method.


/*from  www  .ja  v a 2  s  .  c o  m*/
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
  public static void main(String[] args) {

    Deque<Integer> deque = new ArrayDeque<Integer>(8);

    
    deque.add(25);
    deque.add(30);
    deque.add(20);
    deque.add(40);

    System.out.println(deque);

    boolean retval = deque.remove(30);
    if (retval == true) {
      System.out.println("element 30 is removed from the deque");
    } else {
      System.out.println("element 30 is not contained in the deque");
    }

    System.out.println(deque);
  }
}

The code above generates the following result.