Java List.contains(Object o)

Syntax

List.contains(Object o) has the following syntax.

boolean contains(Object o)

Example

In the following code shows how to use List.contains(Object o) method.


//  ww w  .  j a  va  2  s. co m
import java.util.Arrays;
import java.util.List;
public class Main {
  public static void main(String[] a) {
    List list = Arrays.asList(new String[] { "A", "B", "C", "D" });
    System.out.println(list.contains("C"));
  }
}

The code above generates the following result.