Here you can find the source of toInts(Integer[] values)
public static int[] toInts(Integer[] values)
//package com.java2s; //License from project: Open Source License public class Main { public static final int DEFAULT_INT = 0; public static int[] toInts(Integer[] values) { return toInts(values, DEFAULT_INT); }/*from w w w .j av a 2 s . co m*/ public static int[] toInts(Integer[] values, int defaultValue) { int[] results = new int[0]; if (values != null) { results = new int[values.length]; for (int i = 0; i < results.length; i++) { Integer element = values[i]; try { results[i] = (element != null ? element.intValue() : defaultValue); } catch (Exception ex) { // ex.printStackTrace(); } } } return results; } public static Integer[] toInts(int[] values) { return toInts(values, DEFAULT_INT); } public static Integer[] toInts(int[] values, int defaultValue) { Integer[] results = new Integer[0]; if (values != null) { results = new Integer[values.length]; for (int i = 0; i < results.length; i++) { int element = values[i]; try { results[i] = new Integer(element); } catch (Exception ex) { results[i] = defaultValue; // ex.printStackTrace(); } } } return results; } }