Does it contain certain element
boolean contains(Object o)
- Returns true if this list contains the specified element.
boolean containsAll(Collection<?> c)
- Returns true if this list contains all of the elements of the specified collection.
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
List list = new ArrayList();
list.add("1");
list.add("2");
list.add("3");
list.add("java2s.com");
System.out.println("List has:" + list);
boolean b = list.contains("java2s.com");
System.out.println(b);
}
}
The output:
List has:[1, 2, 3, java2s.com]
true