Java Utililty Methods List Copy

List of utility methods to do List Copy

Description

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

Method

Listcopy(Collection list)
copy
if (list == null || list.isEmpty()) {
    return new ArrayList<T>(0);
return new ArrayList<T>(list);
voidcopy(final List list0, final List list1)
copy
Collections.copy(list0, list1);
Listcopy(java.util.List list)
for providing a copy of a list -- especially useful for providing a concurrency safe iteration of a list
if (list instanceof java.util.ArrayList)
    return (List<T>) ((java.util.ArrayList) list).clone();
else
    return new ArrayList(list);
Listcopy(List master)
copy
if (master == null) {
    return null;
return new ArrayList(master);
Listcopy(List oldlist)
copy
List list = new ArrayList();
for (Iterator i = oldlist.iterator(); i.hasNext();) {
    list.add(i.next());
return list;
Listcopy(List src, boolean immutable)
copy
if (src == null)
    return null;
List<T> result = new ArrayList<>(src);
if (immutable)
    return Collections.unmodifiableList(result);
return result;
Listcopy(List src, int offset, int length)
copy
List<T> items = new ArrayList<T>(length);
for (int i = 0; i < length; i++)
    items.add(src.get(offset + i));
return items;
Listcopy(List master)
copy
if (master == null) {
    return null;
return new ArrayList<E>(master);
Listcopy(List source, int index)
copy
List<Integer> destination = new ArrayList<>();
for (int i = index; i < source.size(); i++) {
    destination.add(new Integer(source.get(i)));
return destination;
Listcopy(List list)
copy
List<T> copy = new ArrayList<T>();
for (int i = 0; i < list.size(); i++) {
    copy.add(list.get(i));
return copy;