Same as Arrays.asList(...), but does automatically conversion of primitive arrays.

@param array
@return List of objects representing the given array contents
192975
public static List<Object> array2ObjectList(final Object array) {
        final int length = Array.getLength(array);
        final List<Object> list = new ArrayList<Object>(length);
        for (int i = 0; i < length; ++i) {
            list.add(Array.get(array, i));
        }
        return list;
    }
208111
public static List primitiveArrayToList(Object array) {
        int size = Array.getLength(array);
        List list = new ArrayList(size);
        for (int i = 0; i < size; i++) {
            Object item = Array.get(array, i);
            if (item != null && item.getClass().isArray() && item.getClass().getComponentType().isPrimitive()) {
                item = primitiveArrayToList(item);
            }
            list.add(item);
        }
        return list;
    }
81570
private static List<Object> asList(final int n, final Object[] o) {
        return Arrays.asList(o).subList(0, n);
    }
379828
public static <T extends Comparable<T>> Integer[] arsort(T[] array) {
        return _asort(array, true);
    }
57304
@SafeVarargs
    public static <V extends Comparable<V>> V[] sort(V... array) {
        Arrays.sort(array);
        return array;
    }
471201
@SafeVarargs
    static <T> List<T> joinArrays(final T[]... arrays) {
        final List<T> all = new ArrayList<>();
        for (final T[] array : arrays) {
            for (int j = 0; j < array.length; j++) {
                all.add(array[j]);
            }
        }
        return all;
    }
1292520
public static Object toWrapperArray(Object array) {
    if (!array.getClass().isArray()) {
      throw new IllegalArgumentException("Must give array object.");
    }
    if (isPrimitiveArray(array.getClass())) {
      int length = Array.getLength(array);
      Object newArray = Array.newInstance(toWrapper(array.getClass().getComponentType()), length);
      for (int i = 0; i < length; i++) {
        Array.set(newArray, i, toWrapper(Array.get(array, i)));
      }
      return newArray;
    } else if (array.getClass().getComponentType().isArray()) {
      int length = Array.getLength(array);
      Object newArray = Array.newInstance(toWrapperArray(array.getClass().getComponentType()), length);
      for (int i = 0; i < length; i++) {
        Array.set(newArray, i, toWrapperArray(Array.get(array, i)));
      }
      return newArray;
    }
    return array;
  }
1137926
public static int[][] toInt(double[][] array) {
        int[][] n = new int[array.length][array[0].length];
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                n[i][j] = (int) array[i][j];
            }
        }
        return n;
    }
1153145
public static <T> T[] listToArray(List<T> list, T[] array) {
        if (list == null || array == null) {
            return null;
        }

        return list.toArray(array);
    }
819565
@Nullable
  public static int[] getIntArray(@Nullable final JsonArray array) {
    if (null == array) return null;
    return IntStream.range(0, array.size()).map(i -> array.get(i).getAsInt()).toArray();
  }
801784
public static Object[] stringListToArray(List<String> list) {
		Object[] params = null;
		if (list != null) {
			params = list.toArray(new String[list.size()]);
		}
		return params;
	}
1213020
public static <T> List<T> arrayToList(T [] array) {
        return new ArrayList<T>(Arrays.asList(array));
    }
1264424
@SuppressWarnings("unchecked")
    @Override
    public final <AT> AT[] toArray(AT[] a) {
        this.readLock.lock();
        try {
            // Verify the array size
            if (a.length < this.size) {
                a =
                        (AT[])
                                java.lang.reflect.Array.newInstance(
                                        a.getClass().getComponentType(), this.size);
            }

            // Trick to avoid generics warning
            final Object[] result = a;

            // Copy over all elements
            int index = 0;
            for (final Queue<T> queue : this.keyedQueues.values()) {
                for (final T e : queue) {
                    result[index++] = e;
                }
            }

            // If array is too big set next element null
            if (a.length > this.size) {
                a[this.size] = null;
            }

            return a;
        } finally {
            this.readLock.unlock();
        }
    }
3554
private Iterator<Object> arrayIt(final Object array) {
        return new Iterator<Object>() {
            private int index = 0;
            private final int length = Array.getLength(array);
            @Override
            public boolean hasNext() {
                return this.index < this.length;
            }
            @Override
            public Object next() {
                try {
                    return Array.get(array, this.index++);
                } catch (Throwable t) {
                    throw new NoSuchElementException(t.getMessage());
                }
            }
        };
    }
566939
private List<Object> convertArray(V8Array arr) {
		List<Object> l = new ArrayList<>();
		for (int i = 0; i < arr.length(); ++i) {
			Object o = arr.get(i);
			if (o instanceof V8Array) {
				o = convert((V8Array)o, List.class);
			} else if (o instanceof V8Object) {
				o = convert((V8Object)o, Map.class);
			}
			l.add(o);
		}
		return l;
	}
585634
public static List<Integer> asList (int[] list)
    {
        if (list == null) {
            return null;
        }
        List<Integer> ilist = new ArrayList<Integer>(list.length);
        for (int ii = 0; ii < list.length; ii++) {
            ilist.add(list[ii]);
        }
        return ilist;
    }
458474
public static <T> Set<T> arrayToSet(T [] array) {
        return new HashSet<T>(Arrays.asList(array));
    }