Here you can find the source of toList(int[] arr)
Parameter | Description |
---|---|
arr | the int array |
public static List<Integer> toList(int[] arr)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { /**/*w ww . j av a2 s.c o m*/ * convert the int array to a list. * @param arr the int array * @return the result list. */ public static List<Integer> toList(int[] arr) { return toList(arr, null); } /** * convert the int array to a list. * @param arr the int array * @param out the out list, can be null * @return the result list. */ public static List<Integer> toList(int[] arr, List<Integer> out) { if (out == null) { out = new ArrayList<>(); } for (int size = arr.length, i = 0; i < size; i++) { out.add(arr[i]); } return out; } }