Java Utililty Methods List from Array

List of utility methods to do List from Array

Description

The list of methods to do List from Array are organized into topic(s).

Method

ArrayListarrayToList(int[] a)
make an Array of the type int[] into ArrayList.
ArrayList<Integer> ret = new ArrayList<Integer>();
for (int i = 0; i < a.length; i++) {
    ret.add(a[i]);
return ret;
ListarrayToList(int[] array)
arrayToList converts an int array to an ArrayList object, then sorts it in descending order.
List<Integer> al = new ArrayList<Integer>();
for (int i : array) {
    al.add(i);
Collections.sort(al, new Comparator<Integer>() {
    public int compare(Integer o1, Integer o2) {
        if (o1 > (int) o2) {
            return -1;
...
ArrayListarrayToList(int[] array)
array To List
if (isEmpty(array)) {
    return null;
ArrayList<Integer> result = new ArrayList<Integer>();
for (int num : array) {
    result.add(num);
return result;
...
ListarrayToList(Object arr[], int from, int length)
array To List
if (arr == null)
    return null;
List<Object> list = new ArrayList<Object>();
for (int i = from; i < length; i++)
    list.add(arr[i]);
return list;
ListarrayToList(Object data)
array To List
ArrayList<Object> list = new ArrayList<Object>();
if (data instanceof Object[]) {
    Object[] o = (Object[]) data;
    for (Object object : o) {
        list.add(object);
} else if (data instanceof Collection) {
    Collection tmp = (Collection) data;
...
ListarrayToList(Object data[])
array To List
List newdata = new ArrayList();
Object aobj[];
int j = (aobj = data).length;
for (int i = 0; i < j; i++) {
    Object curbyte = aobj[i];
    newdata.add(curbyte);
return newdata;
...
ListarrayToList(Object[] arr)
array To List
List<?> list = new ArrayList<>();
if (arr == null) {
    return list;
list = Arrays.asList(arr);
return list;
ListarrayToList(Object[] hyCycles)
array To List
List list = new ArrayList();
Collections.addAll(list, hyCycles);
return list;
ListarrayToList(String[] array, String... defaults)
array To List
List<String> ret;
if (array == null || array.length == 0) {
    ret = Arrays.asList(defaults);
} else {
    ret = new ArrayList<>(array.length);
    for (String entry : array) {
        String[] parts = entry.split(",\\s*");
        ret.addAll(Arrays.asList(parts));
...
ListarrayToList(String[] arrValues)
Convenience method to return a String array as a CSV String.
List values = null;
if (arrValues != null) {
    values = new ArrayList();
    int size = arrValues.length;
    for (int i = 0; i < size; i++) {
        values.add(arrValues[i]);
return values;