Clone the passed list - Android java.util

Android examples for java.util:List

Description

Clone the passed list

Demo Code


//package com.java2s;

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*from  www . j av a 2s .co  m*/
     * Clone the passed list
     *
     * @return the cloned list
     */
    public static <T extends Object> List<T> cloneList(List<T> list) {
        List<T> clone = new ArrayList<>(list.size());
        for (T item : list) {
            clone.add(item);
        }
        return clone;
    }
}

Related Tutorials