int[] result = new int[IntegerArray.length]; for (int i = 0; i < IntegerArray.length; i++) { result[i] = IntegerArray[i].intValue(); } return result; } Apache Commons Lang 工具类 ArrayUtils
添加依赖
org.apache.commons commons-lang3 3.12.0 import org.apache.commons.lang3.ArrayUtils; public class ArrayConvertExample { public static void main(String[] args) { int[] obj = new int[] { 1, 2, 3 }; Integer[] newObj = ArrayUtils.toObject(obj); Integer[] obj2 = new Integer[] { 4, 5, 6 }; int[] newObj2 = ArrayUtils.toPrimitive(obj2); Integer[] obj3 = new Integer[] { 7, 8, null }; int[] newObj3 = ArrayUtils.toPrimitive(obj2, 0); } } ArrayUtils.toObject()与ArrayUtils.toPrimitive()源码如下: package org.apache.commons.lang3; public class ArrayUtils { … public static final Integer[] EMPTY_INTEGER_OBJECT_ARRAY = new Integer[0]; //Convert int[] to Integer[] public static Integer[] toObject(final int[] array) { if (array == null) { return null; } else if (array.length == 0) { return EMPTY_INTEGER_OBJECT_ARRAY; } final Integer[] result = new Integer[array.length]; for (int i = 0; i < array.length; i++) { result[i] = Integer.valueOf(array[i]); } return result; } public static final int[] EMPTY_INT_ARRAY = new int[0]; //Convert Integer[] to int[] public static int[] toPrimitive(final Integer[] array) { if (array == null) { return null; } else if (array.length == 0) { return EMPTY_INT_ARRAY; } final int[] result = new int[array.length];