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(List list)
copy
if (list == null) {
    return null;
List<T> copys = new ArrayList<T>(list.size());
for (T t : list) {
    copys.add(t);
return copys;
...
Listcopy(List list)
Returns a copy of the given list
return new ArrayList<T>(list);
ArrayListcopy(List original)
copy
if (original == null)
    return null;
ArrayList<T> ret = new ArrayList<>(original.size());
for (T x : original)
    ret.add(x);
return ret;
Listcopy(List toCopy)
copy
List<T> res = new ArrayList<>(toCopy.size());
res.addAll(toCopy);
return res;
Listcopy(List toCopy)
Copies the given list.
if (toCopy == null) {
    return null;
final ArrayList<T> result = new ArrayList<T>(toCopy.size());
for (final T element : toCopy) {
    result.add(element);
return result;
...
voidcopy(List[] sourceLists, List[] destLists)
copy
for (int i = 0; i < sourceLists.length; i++) {
    destLists[i].clear();
    for (int j = 0; j < sourceLists[i].size(); j++) {
        destLists[i].add(sourceLists[i].get(j));
ListcopyAndClearList(List sourceList)
Copy items from source to target list; then clear source list and set it to null
ArrayList<String> newList = null;
if (sourceList != null) {
    newList = new ArrayList<String>();
    for (int i = 0; i < sourceList.size(); i++) {
        String oldString = sourceList.set(i, null);
        String newItem = new String(oldString);
        oldString = null;
        newList.add(newItem);
...
ListcopyAndRemove(final List in, final String remove)
copy And Remove
final List<String> list = new ArrayList<String>(in);
list.remove(remove);
return unmodifiableList(list);
Map>copyAndSet(final Map> in, final String key, final String value)
copy And Set
final Map<String, List<String>> ret = newMap();
for (final Map.Entry<String, List<String>> e : in.entrySet()) {
    if (!key.equals(e.getKey())) {
        ret.put(e.getKey(), copy(e.getValue()));
ret.put(key, newList(value));
return unmodifiableMap(ret);
...
ListcopyArrayToList(Object[] input, List output)
copy Array To List
for (int i = 0; i < input.length; i++) {
    output.add((T) input[i]);
return output;