Here you can find the source of asList(int... array)
Parameter | Description |
---|---|
array | The array. |
public static List<Integer> asList(int... array)
//package com.java2s; /*/*from ww w . j a va 2 s .c o m*/ * Copyright (C) 2015 Miquel Sas * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with this program. If not, see * <http://www.gnu.org/licenses/>. */ import java.util.ArrayList; import java.util.List; public class Main { /** * Returns a list given the argument array. * * @param array The array. * @return The list. */ public static List<Integer> asList(int... array) { List<Integer> list = new ArrayList<>(); for (int element : array) { list.add(element); } return list; } /** * Returns a list given the argument array. * * @param array The array. * @return The list. */ public static List<Double> asList(double... array) { List<Double> list = new ArrayList<>(); for (double element : array) { list.add(element); } return list; } /** * Returns a list given the argument array. * * @param <T> The type. * @param array The array. * @return The list. */ @SafeVarargs public static <T> List<T> asList(T... array) { List<T> list = new ArrayList<>(); for (T element : array) { list.add(element); } return list; } }