Javatpoint Logo
Javatpoint Logo

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:

  1. 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

Test it Now

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

Test it Now

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

Test it Now

Output:

The list of vowels is given as : 
[a, e, i, o, u]
The alphabet is not a vowel.
Next TopicJava Deque





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA