Java ArrayList Copy memcpy(ArrayList src)

Here you can find the source of memcpy(ArrayList src)

Description

memcpy

License

Open Source License

Declaration

public static <T> ArrayList<T> memcpy(ArrayList<T> src) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    public static <T> T[] memcpy(T[] src) {
        if (src == null)
            return null;
        return Arrays.copyOf(src, src.length);
    }//from  w  ww .j a v  a 2s  . c o m

    public static <T> ArrayList<T> memcpy(ArrayList<T> src) {
        if (src == null)
            return null;
        ArrayList<T> dst = new ArrayList<T>();
        for (int c = 0; c < src.size(); c++) {
            dst.add(src.get(c));
        }
        return dst;
    }
}