数组复制_copy to list

将一个数组辅助为另一个数组

/**
     * 数组复制
     *
     * @param resourceList 源数组
     * @param target       目标对象
     * @param           目标对象类型
     * @return
     */
    public static <T> List<T> copyBeanList(List<?> resourceList, Class<T> target) {
        List<T> targetList = new LinkedList<>();
        if (null == resourceList || resourceList.isEmpty()) {
            return targetList;
        }
        resourceList.forEach(e -> {
            T o = null;
            try {
                o = target.newInstance();
            } catch (InstantiationException | IllegalAccessException ex) {
                ex.printStackTrace();
            }
            BeanUtils.copyProperties(e, o);
            targetList.add(o);
        });
        return targetList;
    }

你可能感兴趣的:(java,算法,jvm)