LinkedList contains() Method in Java
The Java.util.LinkedList.contains() method is used to check whether an element is present in a LinkedList or not. It takes the element as a parameter and returns True if the element is present in the list.
Parameters: The parameter element is of type LinkedList. This parameter refers to the element whose occurrence is needed to be checked in the list.
Return Value: The method returns True if the element is present in the LinkedList otherwise it returns False.
Below program illustrate the Java.util.LinkedList.conatins() method:
LinkedList:[Geeks, for, Geeks, 10, 20] Does the List contains 'Hello': false Does the List contains '20': true Does the List contains 'Geeks': true
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.