Here you can find the source of toIntArray(ArrayList
Parameter | Description |
---|---|
an | array of Integers |
static protected int[] toIntArray(ArrayList<Integer> array)
//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; } }