ArrayUtil.java 1 import java.util.Random; 2 3 /** 4 This class contains utility methods for array 5 manipulation. 6 */ 7 public class ArrayUtil 8 { 9 /** 10 Creates an array filled with random values. 11 @param length the length of the array 12 @param n the number of possible random values 13 @return an array filled with length numbers between 14 0 and n - 1 15 */ 16 public static int[] randomIntArray(int length, int n) 17 { 18 int[] a = new int[length]; 19 for (int i = 0; i < a.length; i++) 20 a[i] = generator.nextInt(n); 21 22 return a; 23 } 24 25 private static Random generator = new Random(); 26 } 27