Java List Copy copy(Collection list)

Here you can find the source of copy(Collection list)

Description

copy

License

Open Source License

Declaration

public static <T> List<T> copy(Collection<T> list) 

Method Source Code


//package com.java2s;
import java.util.ArrayList;
import java.util.Collection;

import java.util.List;
import java.util.Map;

public class Main {
    public static <T> List<T> copy(Collection<T> list) {
        if (list == null || list.isEmpty()) {
            return new ArrayList<T>(0);
        }//from  w ww .j a v a2 s.c  o  m
        return new ArrayList<T>(list);
    }

    public static <T> boolean isEmpty(T[] vals) {
        return vals == null || vals.length == 0;
    }

    public static <T> boolean isEmpty(T[] vals, boolean checkNullVal) {
        boolean isEmpty = vals == null || vals.length == 0;
        if (isEmpty) {
            return true;
        }
        if (checkNullVal) {
            for (T val : vals) {
                if (val != null) {
                    return false;
                }
            }
            isEmpty = true;
        }
        return isEmpty;
    }

    public static boolean isEmpty(Collection<?> col) {
        return col == null || col.isEmpty();
    }

    public static <T, V> boolean isEmpty(Map<T, V> map) {
        return map == null || map.isEmpty();
    }
}

Related

  1. copy(final List list0, final List list1)
  2. copy(java.util.List list)
  3. copy(List master)
  4. copy(List oldlist)