Java List Copy copyList(List list)

Here you can find the source of copyList(List list)

Description

copy List

License

Apache License

Declaration

public static <T> List<T> copyList(List<T> list) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
    public static <T> List<T> copyList(List<T> list) {
        if (list == null || list.size() == 0) {
            return Collections.emptyList();
        }//from www  .  jav  a2  s. c  o m

        // Verify that there are no null items. This should only happen when there were already errors. If this is
        // the case, we remove them here so parsing can continue; kind of.

        for (int i = list.size() - 1; i >= 0; i--) {
            assert list.get(i) != null;
        }

        return Collections.unmodifiableList(new ArrayList<>(list));
    }
}

Related

  1. copyList(List source, List destination)
  2. copyList(List src)
  3. copyList(List list)
  4. copyList(List list)
  5. copyList(List list)
  6. copyList(List master, List slave)
  7. copyList(List original)
  8. copyList(Object object)
  9. copyListOnlySpecified(List list, int[] indexes)