Java ArrayList to Array toIntArray(ArrayList array)

Here you can find the source of toIntArray(ArrayList array)

Description

Convert an array of Integers into an array of ints.

License

Open Source License

Parameter

Parameter Description
an array of Integers

Return

an array of int[]

Declaration

static protected int[] toIntArray(ArrayList<Integer> array) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2006 IBM Corporation 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://  ww w .  ja v  a 2  s. co  m
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

import java.util.ArrayList;

import java.util.Iterator;

public class Main {
    /**
     * Convert an array of Integers into an array of ints.
     * 
     * @param an
     *            array of Integers
     * 
     * @return an array of int[]
     */
    static protected int[] toIntArray(ArrayList<Integer> array) {

        int[] intArray = new int[array.size()];
        Iterator it = array.iterator();

        int index = 0;

        while (it.hasNext()) {
            intArray[index] = ((Integer) it.next()).intValue();
            index++;
        }

        return intArray;

    }
}

Related

  1. toArray(ArrayList sigs)
  2. toBooleanArray(ArrayList items)
  3. toByteArray(ArrayList in)
  4. toIntArray(ArrayList list)
  5. toIntArray(ArrayList array)
  6. toIntArray(ArrayList input)
  7. toStringArr(ArrayList al)
  8. toStringArray(ArrayList src)
  9. toStringArray(ArrayList src)