![]() |
VOOZH | about |
In Java, the contains() method of LinkedList 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.
boolean contains(Object element);Example: Here, we use the contains() method to check if the element is present in the LinkedList or not.
LinkedList: [Geeks, for, Geeks, 10, 20] The List contains '20': true The List contains 'Hello': false The List contains 'Geeks': true