public class SortTestUtil {
//构造方法私有化,工具类无需产生任何实例
private SortTestUtil() { }
// 生成有n个元素的随机数组,每个元素的随机范围为[rangeL, rangeR]
public static Integer[] generateRandomArray(int number, int rangeL, int rangeR) {
assert rangeL <= rangeR;
Integer[] arr = new Integer[number];
for (int i = 0; i < number; i++) {
arr[i] = new Integer((int) (Math.random() * (rangeR-rangeL+1) + rangeL));
}
return arr;
}
// 打印arr数组的所有内容
public static void printArray(Object arr[]) {
for (int i = 0; i < arr.length; i++){
System.out.print( arr[i] );
System.out.print( ' ' );
}
System.out.println();
return;
}
}