Here you can find the source of toList(int[] from)
Parameter | Description |
---|---|
from | the Array to create the list from. |
public static ArrayList<Integer> toList(int[] from)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { /**/* www . j a v a 2 s.c o m*/ * Creates a new ArrayList from the given Array (by copying). * * @param from the Array to create the list from. * @return a new ArrayList containing all elements in the given Array. */ public static ArrayList<Integer> toList(int[] from) { ArrayList<Integer> list = new ArrayList<>(from.length); for (int i : from) list.add(i); return list; } /** * Creates a new ArrayList from the given Array (by copying). * * @param from the Array to create the list from. * @return a new ArrayList containing all elements in the given Array. */ public static ArrayList<Long> toList(long[] from) { ArrayList<Long> list = new ArrayList<>(from.length); for (long l : from) list.add(l); return list; } }