主要是Integer[]中包含null值,null值可以指定默认值(也可以默认0)。
(最基本的做法,遍历...)
Integer[] integers = {1, 2, 3, null, 4, 5, null, 6};
int length = array.length;
int[] ary = new int[length];
for(int i = 0; i < length; i ++){
ary[i] = array[i] == null ? 0 : array[i];
}来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1754/viewspace-3141157/ ,如需转载,请注明出处,否则将追究法律责任。