Create a new {@link ArrayList} instance containing all elements of the
given list.  This is not a deep clone operation, so the underlying
elements are copied by memory and not cloned.

@param list The list to copy

@return The newly created list
11073
public <T> List<T> cloneList(List<T> list) {
        return new ArrayList<T>(list);
    }
1163516
@SafeVarargs
  public static <T> ArrayList<T> newArrayList(final Iterable<T>... iterables) {
    final ArrayList<T> resultList = newArrayList();
    for (final Iterable<T> oneIterable : iterables) {
      for (final T oneElement : oneIterable) {
        resultList.add(oneElement);
      }
    }
    return resultList;
  }
1206325
public static <T> List<T> toList(final T[] array) {

    if (array != null) {
      List<T> list = new ArrayList<T>(array.length);
      for (T element : array) {
        list.add(element);
      }
      return list;
    } else {
      return new ArrayList<T>(0);
    }
  }
1274818
public static final <T> List<T> create(T... items)
    {
        List<T> list = new ArrayList<>();
        Collections.addAll(list, items);
        return list;
    }
459839
public static <T> T randomElementOf(final List<T> list) {
        if (list.isEmpty()) {
            return null;
        }
        return list.get(nextInt(0, list.size()));
    }
838381
public static <T> List<T> removeDuplicates(final List<T> list) {
        final List<Class> registered = Lists.newArrayList();
        final Iterator it = list.iterator();
        while (it.hasNext()) {
            final Class type = it.next().getClass();
            if (registered.contains(type)) {
                it.remove();
            } else {
                registered.add(type);
            }
        }
        return list;
    }
895166
public static Object add(Object list, Object item)
    {
        if (list==null)
        {
            if (item instanceof List || item==null)
            {
                List l = new ArrayList();
                l.add(item);
                return l;
            }

            return item;
        }

        if (list instanceof List)
        {
            ((List)list).add(item);
            return list;
        }

        List l=new ArrayList();
        l.add(list);
        l.add(item);
        return l;    
    }
815131
public static <T> List<T> create(final T item) {
        final List<T> list = new ArrayList<T>();
        list.add(item);
        return list;
    }
1292114
public static Integer[] box (int[] list)
    {
        if (list == null) {
            return null;
        }
        Integer[] boxed = new Integer[list.length];
        for (int ii = 0; ii < list.length; ii++) {
            boxed[ii] = list[ii];
        }
        return boxed;
    }
84527
public static RecyclableArrayList newInstance(int minCapacity) {
        RecyclableArrayList ret = RECYCLER.get();
        ret.ensureCapacity(minCapacity);
        return ret;
    }
417233
public static <T> JSONArray listToJSONArray(final List<T> list) {
        final JSONArray ret = new JSONArray();

        if (null == list) {
            return ret;
        }

        for (final T object : list) {
            ret.put(object);
        }

        return ret;
    }
1173718
public static <F> FullList<F> newList(final F... elements) {
		final FullList<F> l = new FullList<F>(null, FullList.DEFAULT_CAPACITY);
		l.addAll(Arrays.asList(elements));
		return l;
	}
1084567
public static <T> T randomEle(List<T> list) {
		return randomEle(list, list.size());
	}
812057
public static Object addArray(Object list, Object[] array) {
        for (int i = 0; array != null && i < array.length; i++)
            list = LazyList.add(list, array[i]);
        return list;
    }
704760
public static <T> List<T> toImmutableList(final List<? extends T> list) {
    switch (list.size()) {
      case 0:
        return Collections.emptyList();
      case 1:
        return Collections.singletonList(list.get(0));
      default:
        return Collections.unmodifiableList(list);
    }
  }
726833
@Inline(value="$2.$3copyOf($1)", imported=ImmutableList.class)
	public static <T> List<T> immutableCopy(List<? extends T> list) {
		return ImmutableList.copyOf(list);
	}
1314644
public static Object toArray(Object list, Class<?> clazz) {
        if (list == null)
            return Array.newInstance(clazz, 0);

        if (list instanceof List) {
            List<?> l = (List<?>) list;
            if (clazz.isPrimitive()) {
                Object a = Array.newInstance(clazz, l.size());
                for (int i = 0; i < l.size(); i++)
                    Array.set(a, i, l.get(i));
                return a;
            }
            return l.toArray((Object[]) Array.newInstance(clazz, l.size()));

        }

        Object a = Array.newInstance(clazz, 1);
        Array.set(a, 0, list);
        return a;
    }