VOOZH about

URL: https://www.geeksforgeeks.org/java/linkedlist-contains-method-in-java/

⇱ LinkedList contains() Method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

LinkedList contains() Method in Java

Last Updated : 11 Jul, 2025

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.

Syntax of Java LinkedList contains() Method

boolean contains(Object element);
  • Parameter: 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.

Example: Here, we use the contains() method to check if the element is present in the LinkedList or not.


Output
LinkedList: [Geeks, for, Geeks, 10, 20]

The List contains '20': true
The List contains 'Hello': false
The List contains 'Geeks': true
Comment