Removes the first occurrence of the specified element in this deque (when traversing the deque from head to tail). If
the deque does not contain the element, it is unchanged.
package com.logicbig.example.arraydeque;
import java.util.ArrayDeque;
import java.util.List;
public class RemoveFirstOccurrenceExample {
public static void main(String... args) {
ArrayDeque<Integer> ad = new ArrayDeque<>(List.of(3, 8, 1, 8));
System.out.println(ad);
boolean b = ad.removeFirstOccurrence(8);
System.out.println(b);
System.out.println(ad);
}
}
Output
[3, 8, 1, 8]
true
[3, 1, 8]