Java Deque contains() MethodThe contains() method of Java Deque Interface returns true if the deque contains the specified element. Specified by:
Syntax:Parameter:The above method consists of only one parameter:
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 1Test it NowOutput: 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 2Test it NowOutput: 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 3Test it NowOutput: The list of vowels is given as : [a, e, i, o, u] The alphabet is not a vowel. Next TopicJava Deque |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India