Java Array to List toList(@SuppressWarnings("unchecked") T... ts)

Here you can find the source of toList(@SuppressWarnings("unchecked") T... ts)

Description

to List

License

Apache License

Declaration

public static <T> List<T> toList(@SuppressWarnings("unchecked") T... ts) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
    public static <T> List<T> toList(@SuppressWarnings("unchecked") T... ts) {
        return Arrays.asList(ts);
    }/*from   w ww .  jav a  2s .  co  m*/

    public static <T> List<T> toList(List<T> list, @SuppressWarnings("unchecked") T... ts) {
        List<T> result = new ArrayList<T>(list);
        result.addAll(Arrays.asList(ts));
        return result;
    }

    public static <T> List<T> toList(List<T> list, List<T> list2, @SuppressWarnings("unchecked") T... ts) {
        List<T> result = new ArrayList<T>(list);
        result.addAll(list2);
        result.addAll(Arrays.asList(ts));
        return result;
    }
}

Related

  1. newList(T... objects)
  2. newList(T... objs)
  3. newList(T... ts)
  4. newList(T... values)
  5. newList(V... items)
  6. toList(boolean... booleans)
  7. toList(boolean[] array)
  8. toList(boolean[] array)
  9. toList(Boolean[] list)