public boolean contains(Object) object-element to be searched for
object- element whose presence in this list is to be tested
It returns true if the specified element is found in the list else it returns false.
Code#1: Demonstrate the working of the method contains() in integer
The list contains 2 The list does not contains 5
Code#2: Demonstrate the working of the method contains() in string
The list contains geeks The list does not contains coding
In search operations, we can check if a given element exists in a list or not.
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- Java.util.BitSet class methods in Java with Examples | Set 2
- Java.Lang.Float class in Java
- Java.io.BufferedInputStream class in Java
- Java.io.ObjectInputStream Class in Java | Set 1
- Java.util.BitSet class in Java with Examples | Set 1
- Java.io.File Class in Java
- Java.io.BufferedWriter class methods in Java
- Java.io.DataOutputStream in Java
- Java.io.StreamTokenizer Class in Java | Set 1
- Java.io.InputStream Class in Java
- Java.io.SequenceInputStream in Java
- Java.io.StreamTokenizer Class in Java | Set 2
- Java.io.Console class in Java
- Java.io.FilterOutputStream Class in Java
- Java.io.StringWriter class in Java
- Java.io.CharArrayReader Class in Java
- Java.io.FileInputStream Class in Java
- Java.io.CharArrayWriter class in Java | Set 1
- Java.io.CharArrayWriter class in Java | Set 2
- Java.io.DataInputStream class in Java | Set 1
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.