129
Java Deque contains() Method
The contains() method of Java Deque Interface returns true if the deque contains the specified element.
Specified by:
- contains in interface Collection<E>
Syntax:
Parameter:
The above method consists of only one parameter:
- a.)The element ‘o’ which is already present in the deque and is tested.
Return:
The above method returns a Boolean value, i.e., true if the specified element is already present in the deque .
Throw:
ClassCastException– If the class of the given element is incompatible with the deque.
NullPointerException– If the specified element is a null and the deque does not allow the null elements.
Example 1
Output:
The list of the elements is given as : The final result of the deque is given as : [45.0, 31.0, 456.0, 29.0] The first element is in the list. The second element is not in the list.
Example 2
Output:
The list of the elements is given as : The final result of the deque is given as : [A, J, M, O] The first element is not in the list. The second element is not in the list.
Example 3
Output:
The list of vowels is given as : [a, e, i, o, u] The alphabet is not a vowel.
Next TopicJava Deque