Java List to Int List toIntArray(List list)

Here you can find the source of toIntArray(List list)

Description

Converts the argument to an int[] array.

License

Open Source License

Parameter

Parameter Description
list a List of Integers.

Return

a primitive int[] array.

Declaration

public static int[] toIntArray(List list) 

Method Source Code

//package com.java2s;
/*/* w  ww  .  ja  v  a2  s  . c  o m*/
 * Copyright (c) 2007-2008 Matthew Hall and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Matthew Hall - initial API and implementation
 */

import java.util.List;

public class Main {
    /**
     * Converts the argument to an int[] array.
     * 
     * @param list
     *            a List of Integers.
     * @return a primitive int[] array.
     */
    public static int[] toIntArray(List list) {
        final int[] array = new int[list.size()];
        for (int i = 0; i < array.length; i++)
            array[i] = ((Integer) list.get(i)).intValue();
        return array;
    }
}

Related

  1. toIntArray(final List numbers)
  2. toIntArray(final List list)
  3. toIntArray(final List list)
  4. toIntArray(final List list)
  5. toIntArray(java.util.List list)
  6. toIntArray(List nums)
  7. toIntArray(List ints)
  8. toIntArray(List bytes)
  9. toIntArray(List a)