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