import java.util.Random; /** * A simple class to generate random integer arrays, * often quite useful for testing sorting algorithms. * *

* Written as an example for an ACM Crossroads article * about using javadoc, the Java API * documentation generator of HTML pages. * * @author Kevin Henry * * @link http://www.acm.org/crossroads/ * @link http://www.ece.vill.edu/~khenry/javadoc/ * * @see java.lang.Integer * * @version 0.1 */ public class GenerateIntArray { /** * Create an array of primitive int values. Accept specified * number of values to generate, and an inclusive range within * which the generated values should fall. * *

* This is a trivial method written just to demonstrate how a * comment is written for Javadoc. Notice the special tags: * * @since 0.1 * * @param size the size of the array to create * (the number of values to generate) * @param min the least value that may be generated * @param max the greatest value that may be generated * * @return an array of size primitive int * values between the min and * max range, inclusive */ public int [] generateRandomIntArray (int size, int min, int max) { Random generate = new Random (); int [] array = new int [size]; for (int index = 0; index < size; index++) array [index] = generate.nextInt (max - min + 1) + min; return array; } }