import java.util.Collections; import java.util.ArrayList; /** Generate.java - create test input for sorting algorithms. * Start with the numbers 1 to n, and ask the Java API to shuffle * these numbers. The value n comes from the command line. * The shuffled values will be displayed in standard output. */ public class Generate { public static void main(String [] args) { int n = Integer.parseInt(args[0]); ArrayList a = new ArrayList(); for (int i = 1; i <= n; ++i) a.add(new Integer(i)); Collections.shuffle(a); for (int i = 0; i < a.size(); ++i) System.out.printf("%d ", a.get(i).intValue()); System.out.printf("\n"); } }