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) {
    List<Value> list = Arrays.asList(Value.values());
    System.out.println(list);//w  ww . j  a  v a 2 s  .  c  o  m

    Collections.sort(list, (Value o1, Value o2) -> o1.getValue1() - o2.getValue1());
    System.out.println(list);
    Collections.sort(list, (Value o1, Value o2) -> o1.getValue2() - o2.getValue2());
    System.out.println(list);
}

From source file:Main.java

public static void main(String[] args) {
    String[] cars = { "A", "B", "C", "D" };
    List<String> carList = Arrays.asList(cars);

    for (String car : carList) {
        System.out.println(car);/*from  w  ww  . j  a v a2s . c o m*/
    }
}

From source file:Main.java

public static void main(String[] args) {
    List<String> data = new ArrayList<String>(Arrays.asList(new String[] { "a", "b", "c", "d", "f", "g" }));
    System.out.println(data);//from www  .j  a  v  a 2 s  .  c  om
    removeWithoutUsingRemoveMethod(data, 2);
    System.out.println(data);
}

From source file:Main.java

public static void main(String[] args) {
    Integer[] numbers = { 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 };

    List list = Arrays.asList(numbers);

    for (int i = 0; i < list.size(); i++) {
        System.out.print(list.get(i) + ", ");
    }//  w w w. j  a  v a2s .c  om
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int[] array = new int[10];
    // Fixed-size list
    List list = Arrays.asList(array);
}

From source file:Main.java

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

From source file:MainClass.java

public static void main(String args[]) {
    Integer[] array = { 1, 2, 3, 4, 5 };
    Vector<Integer> v = new Vector<Integer>(Arrays.asList(array));

    System.out.println(v);// www . j a v a 2  s.  co  m
}

From source file:Main.java

public static void main(String[] args) {
    String[] array = { "A", "B", "C", "D" };
    List list = Arrays.asList(array);

    Iterator iterator = list.iterator();
    while (iterator.hasNext()) {
        System.out.println((String) iterator.next());
    }/* w  ww. jav  a  2 s .  c  o m*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    List<Integer> list = Arrays.asList(new Integer[] { 0, 1, 2, 3 });

    int capacity = 100;
    ArrayBlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(capacity, true, list);
    queue.put(0);//  ww w . j  a v  a2 s .c  o m
    queue.put(1);
    queue.put(2);
    System.out.println(queue);
    System.out.println(list);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int[] array = new int[10];

    Set set = new HashSet(Arrays.asList(array));
}