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[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set<String> set = new HashSet<String>(Arrays.asList(elements));

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

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

    for (int i = 0; i < peoples.length; i++) {
        int index = new Random().nextInt(names.size());
        String anynames = names.get(index);
        System.out.println(anynames);

    }//from   ww  w  .j  a  va 2s . c  o  m

}

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);//from w ww .j av  a 2s  .  co m
    System.out.println(set.first());
    System.out.println(set.last());
}

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.subSet("C", "F"));
}

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.hashCode());

}

From source file:MainClass.java

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

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

    System.out.println(set.tailSet("C"));
    System.out.println(set.headSet("C"));
    System.out.println(set.headSet("C\0"));
    System.out.println(set.tailSet("C\0"));
    System.out.println(set.subSet("C", "F\0"));
    System.out.println(set.subSet("C", "C\0"));
    System.out.println(set.subSet("C", "C"));
}

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

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

    set.remove("A");

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

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

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

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

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