package devmanuals.com; import java.util.Deque; import java.util.LinkedList; public class DequeRemoveFirstOccurrence { public static void main(String[] args) { Deque dq = new LinkedList(); dq.add(1); dq.add(2); dq.add(3); dq.add(4); dq.add(3); dq.add(5); System.out.println("Elements of deque : " + dq); System.out.println("Size of deque before removing element : " + dq.size()); // Implementation of the method boolean bol = dq.removeFirstOccurrence(3); if (bol == true) { System.out.println("The element is matched and "); System.out.println("removed it from deque then new deque = " + dq); System.out.println("Element is Removed = " + bol); System.out.println("Size of deque = " + dq.size()); } else { System.out.println("The element did not matched "); System.out.println("therefore deque remains unchanged " + dq); System.out.println("Element is Removed = " + bol); System.out.println("Size of deque = " + dq.size()); } } }