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