Here you can find the source of asList(T... a)
Parameter | Description |
---|---|
T | type of list elements |
a | An array or sequence of params of type T |
public static <T> ArrayList<T> asList(T... a)
//package com.java2s; /*/*from w ww . j a va 2 s. c o m*/ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: * */ import java.util.ArrayList; public class Main { /** * Return an ArrayList with the passed array or elements * as the initial contents. Differs from Arrays#asList() in that * the list is not fixed sized. * @param <T> type of list elements * @param a An array or sequence of params of type T */ public static <T> ArrayList<T> asList(T... a) { ArrayList<T> result = new ArrayList<T>(); for (T t : a) { result.add(t); } return result; } }