Here you can find the source of toList(final int[] array)
Parameter | Description |
---|---|
array | Array to convert |
public static List<Integer> toList(final int[] array)
//package com.java2s; /*/*from www.j av a2 s . c o m*/ * Nividic development code * * This code may be freely distributed and modified under the * terms of the GNU Lesser General Public Licence. This should * be distributed with the code. If you do not have a copy, * see: * * http://www.gnu.org/copyleft/lesser.html * * Copyright for this code is held jointly by the microarray platform * of the ?cole Normale Sup?rieure and the individual authors. * These should be listed in @author doc comments. * * For more information on the Nividic project and its aims, * or to join the Nividic mailing list, visit the home page * at: * * http://www.transcriptome.ens.fr/nividic * */ import java.util.ArrayList; import java.util.List; public class Main { /** * Convert an array of int to a list of Integers * @param array Array to convert * @return a new list of integers */ public static List<Integer> toList(final int[] array) { if (array == null) return null; final ArrayList<Integer> result = new ArrayList<Integer>( array.length); for (int i = 0; i < array.length; i++) result.add(Integer.valueOf(array[i])); return result; } /** * Convert an array of double to a list of Double * @param array Array to convert * @return a new list of Doubles */ public static List<Double> toList(final double[] array) { if (array == null) return null; final ArrayList<Double> result = new ArrayList<Double>(array.length); for (int i = 0; i < array.length; i++) result.add(Double.valueOf(array[i])); return result; } /** * Convert an array of booleans to a list of Booleans * @param array Array to convert * @return a new list of Booleans */ public static List<Boolean> toList(final boolean[] array) { if (array == null) return null; final ArrayList<Boolean> result = new ArrayList<Boolean>( array.length); for (int i = 0; i < array.length; i++) result.add(Boolean.valueOf(array[i])); return result; } }