Example usage for java.util Arrays asList

List of usage examples for java.util Arrays asList

Introduction

In this page you can find the example usage for java.util Arrays asList.

Prototype

@SafeVarargs
@SuppressWarnings("varargs")
public static <T> List<T> asList(T... a) 

Source Link

Document

Returns a fixed-size list backed by the specified array.

Usage

From source file:MainClass.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set set = new HashSet(Arrays.asList(elements));

    set.remove("A");

    System.out.println(set);/*from   www.  j  a v a2s.  c  o  m*/
}

From source file:MainClass.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set set = new HashSet(Arrays.asList(elements));

    set.add("Z");

    System.out.println(set);/*from   ww  w .j a  v  a 2 s . c o  m*/
}

From source file:MainClass.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set set = new HashSet(Arrays.asList(elements));

    elements = new String[] { "A", "B", "C" };
    Set set2 = new HashSet(Arrays.asList(elements));

    System.out.println(set.containsAll(set2));
}

From source file:MainClass.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set set = new HashSet(Arrays.asList(elements));

    elements = new String[] { "A", "B", "C", "D" };
    Set set2 = new HashSet(Arrays.asList(elements));

    System.out.println(set.equals(set2));
}

From source file:Main.java

public static void main(String[] args) {
    String[] peoples = { "A", "B", "C", "D", "E", "F" };
    List<String> names = Arrays.asList(peoples);
    Collections.shuffle(names);//from w w  w. j a v  a 2 s.c om
    for (String name : names) {
        System.out.print(name + " ");
    }
}

From source file:MainClass.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set set = new HashSet(Arrays.asList(elements));

    elements = new String[] { "B", "D", "F", "G", "1", "2", "3", "4" };
    Set set2 = new HashSet(Arrays.asList(elements));

    set.removeAll(set2);/*from w w w .j a va 2  s.c  o m*/
    System.out.println(set);
}

From source file:MainClass.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set set = new HashSet(Arrays.asList(elements));

    elements = new String[] { "E", "F" };

    set.addAll(Arrays.asList(elements));

    System.out.println(set);/*from  w ww.j  a va2 s. c om*/
}

From source file:Main.java

public static void main(String[] args) {
    String elements[] = { "M", "N", "O", "P", "Q" };
    Set set = new HashSet(Arrays.asList(elements));

    String[] strObj = new String[set.size()];

    strObj = (String[]) set.toArray(strObj);

    for (int i = 0; i < strObj.length; i++) {
        System.out.println(strObj[i]);
    }/*from  w ww  .j a v  a2 s  . co  m*/
    System.out.println(set);
}

From source file:Main.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set<String> set = new HashSet<String>(Arrays.asList(elements));

    System.out.println(set.contains("A"));
}

From source file:Main.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set<String> set = new HashSet<String>(Arrays.asList(elements));

    System.out.println(set.size());
}