ArrayDeque.removeFirstOccurrence(Object): This method is available in java.util.ArrayDeque class of Java.
Syntax:
boolean java.util.ArrayDeque.removeFirstOccurrence(Object o)
This method takes one argument. This method removes the first occurrence of the specified element in this deque.
Parameters: One parameter is required for this method.
o: the element to be removed from this deque if present.
Returns: true if the deque contained the specified element.
Exceptions: NA
Approach
Java
import java.util.ArrayDeque;public class ArrayDequeremoveFirstOccurrence {public static void main(String[] args) {ArrayDeque<Integer> arrayDeque =new ArrayDeque<Integer>();arrayDeque.add(1);arrayDeque.add(4);Object o = 3;System.out.println(arrayDeque.removeFirstOccurrence(o));}}
Output:
false
No comments:
Post a Comment