Java Array to List toList(final int[] array)

Here you can find the source of toList(final int[] array)

Description

to List

License

Open Source License

Parameter

Parameter Description
array a parameter

Return

List

Declaration

public static List<Integer> toList(final int[] array) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Manchester Centre for Integrative Systems Biology
 * University of Manchester/*from w w  w.  j a va  2 s.  c o m*/
 * Manchester M1 7ND
 * United Kingdom
 * 
 * Copyright (C) 2007 University of Manchester
 * 
 * This program is released under the Academic Free License ("AFL") v3.0.
 * (http://www.opensource.org/licenses/academic.php)
 *******************************************************************************/

import java.util.*;

public class Main {
    /**
     * 
     * @param array
     * @return List<Integer>
     */
    public static List<Integer> toList(final int[] array) {
        final List<Integer> list = new ArrayList<>();

        for (final int value : array) {
            list.add(Integer.valueOf(value));
        }

        return list;
    }

    /**
     * 
     * @param array
     * @return List<Double>
     */
    public static List<Double> toList(final double[] array) {
        final List<Double> list = new ArrayList<>();

        for (final double value : array) {
            list.add(Double.valueOf(value));
        }

        return list;
    }
}

Related

  1. toList(E... values)
  2. toList(E[] array, int fromIndex, int toIndex)
  3. toList(final double[] array)
  4. toList(final E[] array)
  5. toList(final float[] array)
  6. toList(final int[] array)
  7. ToList(final Object[] array)
  8. toList(final Object[] objects)
  9. toList(final T... objects)