Here you can find the source of copyOf(List
Parameter | Description |
---|---|
T | Type of list elements |
list | List to copy |
list
containing the same elements
public static <T> List<T> copyOf(List<T> list)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { /**/*from w w w .j a va 2 s . co m*/ * Returns a copy of the given list. * * @param <T> * Type of list elements * @param list * List to copy * @return Copy of <code>list</code> containing the same elements */ public static <T> List<T> copyOf(List<T> list) { List<T> result = new ArrayList<>(list.size()); result.addAll(list); return result; } }