对primitive[]数组进行排序
直接使用Arrays.sort()即可。不必自己去写排序算法了。
拷贝一个范围内的数组
Arrays.copyOfRange( array, startIndex, endIndex);
include startIndex...
exclude endIndex...
用相同默认值,初始化一个数组
参数除了int类型,还能是多种primitive类型
/** * Assigns the specified int value to each element of the specified array * of ints. * * @param a the array to be filled * @param val the value to be stored in all elements of the array */ public static void fill(int[] a, int val) { for (int i = 0, len = a.length; i < len; i++) a[i] = val; }