Java List check if an element exists

Description

Java List check if an element exists

import java.util.Arrays;
import java.util.List;
public class Main {
  public static void main(String[] a) {
    List<String> list = Arrays.asList(
        new String[] { "CSS", "HTML", "Java", "Javascript" });
    System.out.println(list.contains("Java"));
    // w  w  w  . j  ava 2  s  . com
    System.out.println(list.contains("demo2s.com"));
  }
}



PreviousNext

Related