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[] = { "java2s.com", "C", "D", "G", "F" };
    TreeSet<String> set = new TreeSet<String>(Arrays.asList(elements));
    TreeSet<String> set1 = new TreeSet<String>(set);
    System.out.println(set1);// ww  w.  ja v a 2  s  . c o m
}

From source file:Main.java

public static void main(String args[]) {
    String str[] = { "B", "H", "L", "M", "R" };
    List list = Arrays.asList(str);
    System.out.println(Collections.min(list));
    System.out.println(Collections.max(list));
    Comparator comp = Collections.reverseOrder();
    System.out.println(Collections.min(list, comp));
    System.out.println(Collections.max(list, comp));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String[] strArray = new String[] { "z", "a", "A" };
    List list = Arrays.asList(strArray);
    Collections.sort(list);/*w w  w .j a v  a 2  s .c  om*/

    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);

    Collections.sort(list, Collections.reverseOrder());

    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
    Collections.reverse(list);
}

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

    set.removeAll(set2);//from   w  w w . ja v  a 2s . 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));

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

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

    System.out.println(set);//from  www. j av  a2 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));

    Object[] arrObj = set.toArray();

    for (int i = 0; i < arrObj.length; i++) {
        System.out.println(arrObj[i]);
    }// w w w  .  j  av a 2s  .  c  o  m

    System.out.println(set);
}

From source file:Main.java

public static void main(final String[] args) {
    sortDates(Arrays.asList(new DAY[] { DAY.MON, DAY.WED, DAY.TUE, DAY.THU, DAY.SUN, DAY.SAT, DAY.FRI }));
}

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);//from w w w.  j  a va2 s  .c o  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[] = { "java2s.com", "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 args[]) throws Exception {
    String elements[] = { "A", "B", "C", "D" };

    List list = new ArrayList(Arrays.asList(elements));

    System.out.println(list);//from  w ww  .  j  a v a 2s .co  m
}