Java Deque .removeLastOccurrence (Object o)

Syntax

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

boolean removeLastOccurrence(Object o)

Example

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


import java.util.ArrayDeque;
import java.util.Deque;
/*  w  ww .j a v  a 2s . c o m*/
public class Main {
   public static void main(String[] args) {
      
      
      Deque<Integer>  deque = new ArrayDeque<Integer> (8);

      
      deque.add(1);
      deque.add(2);
      deque.add(3);
      deque.add(3);

      System.out.println(deque);

      deque.removeLastOccurrence(3);

      System.out.println(deque);
   }
}

The code above generates the following result.