Java Data Type How to - Check containment in a Set of strings


We would like to know how to check containment in a Set of strings.


import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/*w  ww .  j  a v  a  2s  .  com*/
public class Main {

  public static void main(final String[] args) {
    final Set<String[]> s = new HashSet<String[]>();
    final Set<List<String>> s2 = new HashSet<List<String>>();

    s.add(new String[] { "lucy", "simon" });
    s2.add(Arrays.asList(new String[] { "lucy", "simon" }));

    System.out.println(s.contains(new String[] { "lucy", "simon" })); // false
        .asList(new String[] { "lucy", "simon" }))); // true