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

ArrayListcopyNullSafeMutableList(Collection list)
copy Null Safe Mutable List
if (list == null)
    throw new NullPointerException("list");
ArrayList<E> result = new ArrayList<E>(list);
for (E element : result) {
    if (element == null)
        throw new NullPointerException("element");
return result;
...
ListcopyObjectList(List objects)
Get a copy of a list of objects
List<Object> answer = new ArrayList<Object>();
if (objects == null)
    return null;
for (Object o : objects) {
    answer.add(o);
return answer;
ListcopyOf(List list)
Returns a copy of the given list.
List<T> result = new ArrayList<>(list.size());
result.addAll(list);
return result;
ListcopyOf(List values)
copy Of
return new ArrayList<T>(values);
ListcopyOfRange(List list, int from, int to)
Returns a new list containing all elements of the original list with an index in [from;to]
if (from < 0 || from >= list.size() || to < 0 || to >= list.size() || from > to)
    throw new IllegalArgumentException("Illegal extraction bounds");
List<T> result = new ArrayList<>(to - from + 1);
for (int i = from; i <= to; i++)
    result.add(list.get(i));
return result;
voidcopyProbabilities(List targetProbs, List destinationProbs)
Copy the values of target probs into destination probs
for (int index = 0; index < targetProbs.size(); index++) {
    destinationProbs.set(index, targetProbs.get(index));
ListcopyQueryFilters(List queryFilters)
copy Query Filters
return queryFilters != null ? new ArrayList<String>(queryFilters) : new ArrayList<String>();
java.util.ListcopySafelyToObjectList(java.util.List list)
copy Safely To Object List
java.util.Iterator<?> it = list.iterator();
java.util.List<Object> castedCopy = new java.util.ArrayList<Object>();
while (it.hasNext()) {
    castedCopy.add(it.next());
return castedCopy;
ArrayListcopyStringList(List l1)
copy String List
if (l1 == null) {
    return null;
ArrayList<String> l2 = new ArrayList<String>(l1.size());
for (String str : l1) {
    l2.add(str);
return l2;
...
ListcopyStringList(List list)
copy String List
List<String> result = new ArrayList<String>(list.size());
result.addAll(list);
return result;