Java Utililty Methods List Clone

List of utility methods to do List Clone

Description

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

Method

Listclone(final List list)
Clone a list, not its content
List<E> newInstance;
try {
    newInstance = list.getClass().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
    newInstance = new ArrayList<>();
newInstance.addAll(list);
return newInstance;
...
Listclone(List in)
clone
ArrayList<E> out = new ArrayList<E>(in.size());
out.addAll(in);
return out;
List>clone(List> doc)
clone
List<List<String>> docClone = new ArrayList<List<String>>();
for (List<String> tokens : doc) {
    List<String> tokensClone = new ArrayList<String>();
    for (String token : tokens) {
        tokensClone.add(token);
    docClone.add(tokensClone);
return docClone;
Listclone(List list)
clone
List<Object> copy = new ArrayList<Object>(list.size());
for (Object o : list)
    copy.add(o);
return copy;
Listclone(List list)
clone
if (list == null) {
    return null;
List<String> newList = new ArrayList<String>();
for (int i = 0, k = list.size(); i < k; i++) {
    newList.add(list.get(i));
return newList;
...
Listclone(List input)
clone
if (input == null) {
    return null;
List<T> copy = new ArrayList<T>();
for (T object : input) {
    copy.add(object);
return copy;
...
ListcloneAdd(final List list, final E... element)
Clone a list and add N element to it.
final List<E> retList = clone(list);
Collections.addAll(retList, element);
return retList;
ListCloneList(final Collection list)
Clone List
return new ArrayList(list);
ListcloneList(final List l, final int n)
Creates a list containing the specified list N times in a row.
if (l == null) {
    throw new IllegalArgumentException("The list to be cloned must not be null.");
if (n < 0) {
    throw new IllegalArgumentException("When cloning a list, N must be non-negative (" + n + ")");
if (n == 0 || isEmpty(l)) {
    return Collections.emptyList();
...
ListcloneList(List aList)
clone List
if (aList == null)
    return null;
if (aList instanceof ArrayList) {
    ArrayList theList = (ArrayList) aList;
    return (List) theList.clone();
} else
    throw new IllegalArgumentException();