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:Main.java

public static void main(String args[]) throws Exception {

    String elements[] = { "A", "C", "D", "G", "F" };
    TreeSet<String> set = new TreeSet<String>(Arrays.asList(elements));

    System.out.println(set.headSet("D"));
    System.out.println(set.tailSet(""));
}

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));

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

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

    for (int i = 0; i < strObj.length; i++) {
        System.out.println(strObj[i]);
    }//  w  ww. j  a va2  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  w w .j  a  v  a 2s .  co m

    set.clear();

    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));

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

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

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));

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

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

From source file:Main.java

public static void main(String[] args) {
    String[] array = { "A", "B", "C", "D", "E" };

    List<String> list = Arrays.asList(array);
    System.out.println("List         : " + list);

    List<String> reversedView = reversedView(list);
    System.out.println("Reversed view: " + reversedView);
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    String elements[] = { "A", "C", "D", "G", "F" };
    Set set = new TreeSet(Arrays.asList(elements));

    System.out.println(set);//from w ww  .  java 2 s .  c om
}

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));

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

    set.removeAll(set2);/*from  w w w .  ja  v a  2  s  .com*/
    System.out.println(set);
}

From source file:Main.java

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

    HashSet set2 = ((Set) ((HashSet) set).clone());

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

From source file:Main.java

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

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

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