Integer []arr1={1,2,3,4,5};System.out.println(Arrays.toString(arr1));System.out.println(Arrays.toString(Arrays.copyOf(arr1,arr1.length+3)));
输出:
[1, 2, 3, 4, 5][1, 2, 3, 4, 5, null, null, null]
如果改为int类型:
[1, 2, 3, 4, 5][1, 2, 3, 4, 5, 0, 0, 0]
本文共 295 字,大约阅读时间需要 1 分钟。
Integer []arr1={1,2,3,4,5};System.out.println(Arrays.toString(arr1));System.out.println(Arrays.toString(Arrays.copyOf(arr1,arr1.length+3)));
输出:
[1, 2, 3, 4, 5][1, 2, 3, 4, 5, null, null, null]
如果改为int类型:
[1, 2, 3, 4, 5][1, 2, 3, 4, 5, 0, 0, 0]
转载于:https://my.oschina.net/vincentzhao/blog/386970