Here you can find the source of toPrimitiveArray(Integer[] array)
public static int[] toPrimitiveArray(Integer[] array)
//package com.java2s; //License from project: Open Source License public class Main { public static int[] toPrimitiveArray(Integer[] array) { int[] result = new int[array.length]; for (int i = 0; i < array.length; i++) result[i] = (array[i] == null ? 0 : array[i]); return result; }/*w w w . java 2 s. c o m*/ public static double[] toPrimitiveArray(Double[] array) { double[] result = new double[array.length]; for (int i = 0; i < array.length; i++) result[i] = (array[i] == null ? 0 : array[i]); return result; } public static float[] toPrimitiveArray(Float[] array) { float[] result = new float[array.length]; for (int i = 0; i < array.length; i++) result[i] = (array[i] == null ? 0 : array[i]); return result; } public static byte[] toPrimitiveArray(Byte[] array) { byte[] result = new byte[array.length]; for (int i = 0; i < array.length; i++) result[i] = (array[i] == null ? 0 : array[i]); return result; } public static short[] toPrimitiveArray(Short[] array) { short[] result = new short[array.length]; for (int i = 0; i < array.length; i++) result[i] = (array[i] == null ? 0 : array[i]); return result; } public static long[] toPrimitiveArray(Long[] array) { long[] result = new long[array.length]; for (int i = 0; i < array.length; i++) result[i] = (array[i] == null ? 0 : array[i]); return result; } public static boolean[] toPrimitiveArray(Boolean[] array) { boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) result[i] = (array[i] == null ? false : array[i]); return result; } public static char[] toPrimitiveArray(Character[] array) { char[] result = new char[array.length]; for (int i = 0; i < array.length; i++) result[i] = (array[i] == null ? ' ' : array[i]); return result; } }