How to check if ArrayDeque contains element in Java ?

Declaration : [crayon-5a1e830332639504117264/] Explanation : Purpose The java.util.ArrayDeque.contains(Object) returns true if this deque contains the specified element. Parameters o ===> The object to be checked as contained in deque. Return Value This method returns true if this deque contains the specified element else false. Exception NA Java Program : Example Below example will explain java.util.ArrayDeque.contains() method. [crayon-5a1e830332644208614314/] Output of Program : [crayon-5a1e830332648947992507/]

How to get copy of ArrayDeque in Java ?

Declaration : [crayon-5a1e830333041731977249/] Explanation : Purpose The java.util.ArrayDeque.clone() method returns a copy of this deque. Parameters NA Return Value This method returns a copy of this deque. Exception NA Java Program : Example Below example will explain java.util.ArrayDeque.getFirst() method. [crayon-5a1e830333048165542846/] Output of Program : [crayon-5a1e83033304c848072946/]

How to remove All elements in ArrayDeque in Java ?

Declaration : [crayon-5a1e830333433419718970/] Explanation : Purpose The java.util.ArrayDeque.clear() method removes all of the elements from this deque. Parameters NA Return Value This method does not return any value. Exception NA Java Program : Example Below example will explain java.util.ArrayDeque.clear() method. [crayon-5a1e83033343b258853218/] Output of Program : [crayon-5a1e83033343e507346256/]

How to insert element at end of ArrayDeque in Java ?

Declaration : [crayon-5a1e830333806222056826/] Explanation : Purpose The java.util.ArrayDeque.addLast(E e) method inserts the specified element E at the end of the deque. Parameters e ===> The element to be added at the end. Return Value This method does not return any value. Exception NullPointerException -- if the specified element is null. Java Program : Example Below example will explain java.util.ArrayDeque.addLast(E) method. [crayon-5a1e83033380e381075193/] Output of Program : [crayon-5a1e830333812627850549/]

How to insert element at start of ArrayDeque in Java ?

Declaration : [crayon-5a1e830333bd0009987860/] Explanation : Purpose The java.util.ArrayDeque.addFirst(E e) method inserts the specified element E at the front of the deque. Parameters e ===> The element to be added in the deque. Return Value This method does not return any value. Exception NullPointerException -- if the specified element is null. Java Program : Example Below example will explain java.util.ArrayDeque.addFirst(E) method. [crayon-5a1e830333bd7739565542/] Output of Program : [crayon-5a1e830333bdb913053300/]

How to add element to ArrayDeque in Java ?

Declaration : [crayon-5a1e830333f91448961330/] Explanation : Purpose The java.util.ArrayDeque.add(E e) method inserts the specified element E at the end of the deque. This method is equivalent to addLast(E). Parameters e ===> The element to be added in the deque. Return Value This method returns true if given element is added successully into the deque otherwise it returns false. Exception NullPointerException -- if the specified element is null. Java Program : Example Below example will explain java.util.ArrayDeque.add(E) method. [crayon-5a1e830333f99094166053/] Output of Program : [crayon-5a1e830333f9d990797888/]

How to return elements of ArrayDeque as array in Java ?

Declaration : [crayon-5a1e830334353083834906/] Explanation : Purpose The java.util.ArrayDeque.toArray() method returns an array containing all of the elements in this deque in proper sequence. Parameters NA Return Value This method returns an array containing all of the elements in this deque. Exception NA Java Program : Example Below example will explain java.util.ArrayDeque.toArray() method. [crayon-5a1e83033435a469283900/] Output of Program : [crayon-5a1e83033435f102745760/]

How to calculate size of ArrayDeque in Java ?

Declaration : [crayon-5a1e830334723433380271/] Explanation : Purpose The java.util.ArrayDeque.size() method returns the number of elements in this deque. Parameters NA Return Value This method returns the number of elements in this deque. Exception NA Java Program : Example Below example will explain java.util.ArrayDeque.size() method. [crayon-5a1e83033472a492164176/] Output of Program : [crayon-5a1e83033472e208193779/]

How to remove last element of ArrayDeque in Java ?

Declaration : [crayon-5a1e830334afc355496781/] Explanation : Purpose The java.util.ArrayDeque.removeLast() method retrieves and removes the last element of this deque. Parameters NA Return Value This method returns the tail (last element) of this deque. Exception NoSuchElementException -- if this deque is empty. Java Program : Example Below example will explain java.util.ArrayDeque.removeLast() method. [crayon-5a1e830334b03506935098/] Output of Program : [crayon-5a1e830334b07062765329/]

How to remove first occurrence of element of ArrayDeque in Java ?

Declaration : [crayon-5a1e830334ec7015785785/] Explanation : Purpose The java.util.ArrayDeque.removeFirstOccurrence(Object) method removes the first occurrence of the specified element in this deque. Parameters o ===> The element whose first occurrence is to be removed from this deque if present. Return Value This method returns true if the deque contains the specified element. Exception NA Java Program : Example Below example will explain java.util.ArrayDeque.removeFirstOccurrence(o) method. [crayon-5a1e830334ecf212999780/] Output of Program : [crayon-5a1e830334ed2983565628/]

How to remove first element of ArrayDeque in Java ?

Declaration : [crayon-5a1e83033529f142508723/] Explanation : Purpose The java.util.ArrayDeque.removeFirst() method retrieves and removes the first element of this deque. Parameters NA Return Value This method returns the head (first element) of this deque. Exception NoSuchElementException -- if this deque is empty. Java Program : Example Below example will explain java.util.ArrayDeque.removeFirst() method. [crayon-5a1e8303352a6414931565/] Output of Program : [crayon-5a1e8303352aa318026124/]

How to remove element of ArrayDeque in Java ?

Declaration : [crayon-5a1e830335671222492886/] Explanation : Purpose The java.util.ArrayDeque.remove() method retrieves and removes the head of the queue represented by this deque. Parameters NA Return Value This method returns the head of the queue represented by this deque. Exception NoSuchElementException -- if this deque is empty. Java Program : Example Below example will explain java.util.ArrayDeque.remove() method. [crayon-5a1e830335678086188743/] Output of Program : [crayon-5a1e83033567c248299793/]

How to push an element to ArrayDeque in Java ?

Declaration : [crayon-5a1e830335a4e075657318/] Explanation : Purpose The java.util.ArrayDeque.push(E e) method pushes an element E onto the stack represented by this deque. Parameters e ===> The element to be pushed in the deque. Return Value This method does not return any value. Exception NullPointerException -- if the specified element is null. Java Program : Example Below example will explain java.util.ArrayDeque.push() method. [crayon-5a1e830335a55730535923/] Output of Program : [crayon-5a1e830335a59720608525/]

How to insert specific element to last of ArrayDeque in Java ?

Declaration : [crayon-5a1e830335e19499373440/] Explanation : Purpose The java.util.ArrayDeque.offerLast(E e) method inserts the specified element E at the end of this deque. Parameters e ===> The element to be added at the end. Return Value This method returns true if the element was added to this deque else false. Exception NullPointerException -- if the specified element is null. Java Program : Example Below example will explain java.util.ArrayDeque.offerLast() method. [crayon-5a1e830335e20168572272/] Output of Program : [crayon-5a1e830335e24514047519/]

How to pop element from ArrayDeque in Java ?

Declaration : [crayon-5a1e830336202034748688/] Explanation : Purpose The java.util.ArrayDeque.pop() method pops an element from the stack represented by this deque. Parameters NA Return Value This method returns the element at the front of this deque. Exception NoSuchElementException -- if this deque is empty. Java Program : Example Below example will explain java.util.ArrayDeque.pop() method. [crayon-5a1e830336209926267405/] Output of Program :[crayon-5a1e83033620d920902237/]

How to retrieve last element of ArrayDeque in Java?

Declaration : [crayon-5a1e8303365cf503040184/] Explanation : Purpose The java.util.ArrayDeque.peekLast() method retrieves the last element of this deque(but does not remove). Returns null if this deque is empty. Parameters NA Return Value This method returns the tail of this deque or null if this deque is empty. Exception NA Java Program : Example Below example will explain java.util.ArrayDeque.peekLast() method. [crayon-5a1e8303365d7074247983/] Output of Program : [crayon-5a1e8303365da822141571/]

How to retrieve first element of ArrayDeque in Java ?

Declaration : [crayon-5a1e83033698e863605988/] Explanation : Purpose The java.util.ArrayDeque.peekFirst() method retrieves the first element of this deque (but does not remove) .Returns null if this deque is empty. Parameters NA Return Value This method returns the head of this deque or null if this deque is empty. Exception NA Java Program : Example Below example will explain java.util.ArrayDeque.peekFirst() method. [crayon-5a1e830336995095390776/] Output of Program : [crayon-5a1e830336999838802590/]

How to retrieve element of ArrayDeque in Java ?

Declaration : [crayon-5a1e830336d62344511699/] Explanation : Purpose The java.util.ArrayDeque.peek() method retrieves the head of the queue(but does not remove) represented by this deque.Returns null if this deque is empty. Parameters NA Return Value This method returns the head of the queue represented by this deque or null if this deque is empty. Exception NA Java Program : Example Below example will explain java.util.ArrayDeque.peek() method. [crayon-5a1e830336d69419080759/] Output of Program : [crayon-5a1e830336d6d828317987/]

How to remove head element of ArrayDeque in Java ?

Declaration : [crayon-5a1e83033713a408719178/] Explanation : Purpose The java.util.ArrayDeque.poll() retrieves and removes the head of the queue represented by this deque.Returns null if this deque is empty. Parameters NA Return Value This method returns the head of the queue represented by this deque or null if this deque is empty. Exception NA Java Program : Example Below example will explain java.util.ArrayDeque.poll() method. [crayon-5a1e830337141818164643/] Output of Program : [crayon-5a1e830337145849153327/]

How to remove first element of ArrayDeque in Java ?

Declaration : [crayon-5a1e83033751f871106165/] Explanation : Purpose The java.util.ArrayDeque.pollLast() retrieves and removes the last element of this deque. Returns null if this deque is empty. Parameters NA Return Value This method returns the tail of this deque or null if this deque is empty. Exception NA Java Program : Example Below example will explain java.util.ArrayDeque.pollLast() method. [crayon-5a1e830337526660098461/] Output of Program : [crayon-5a1e83033752b340880995/]

How to remove first element of ArrayDeque in Java ?

Declaration : [crayon-5a1e8303378ff487290233/] Explanation : Purpose The java.util.ArrayDeque.pollFirst() method retrieves and removes the first element of this deque.Returns null if this deque is empty. Parameters NA Return Value This method returns the head of this deque or null if this deque is empty. Exception NA Java Program : Example Below example will explain java.util.ArrayDeque.pollFirst() method. [crayon-5a1e830337907291226417/] Output of Program : [crayon-5a1e83033790b058796376/]