Here you can find the source of toIntArray(final List
Parameter | Description |
---|---|
list | Integer list to convert. |
public static int[] toIntArray(final List<Integer> list)
//package com.java2s; // and/or modify it under the terms of the GNU General Public License import java.util.List; public class Main { /**//from ww w . j ava 2 s . c om * Convert integer list to array. * * @param list * Integer list to convert. * @return Integer array. */ public static int[] toIntArray(final List<Integer> list) { int[] ret = new int[list.size()]; int pos = 0; for (Integer it : list) { ret[pos] = it.intValue(); ++pos; } return ret; } public static int intValue(final Object value) { if (value instanceof Byte) { return ((Byte) value).intValue() & 0xFF; } if (value instanceof Short) { return ((Short) value).intValue() & 0xFFFF; } return ((Number) value).intValue(); } }