Generator.java


Below is the syntax highlighted version of Generator.java from §4.1 Performance.


/******************************************************************************
 *  Compilation:  javac Generator.java
 *  Execution:    java Generator n
 *
 *  Generate n random 32-bit ints and prints the resuts to
 *  standard output.
 *
 ******************************************************************************/

public class Generator {
    public static void main(String[] args) {
        int n = Integer.parseInt(args[0]);
        for (int i = 0; i < n; i++) {
            int r = StdRandom.uniformInt(-500000000, 500000000);
            StdOut.println(r);
        }
    }

}


Copyright © 2000–2022, Robert Sedgewick and Kevin Wayne.
Last updated: Thu Aug 11 10:28:22 EDT 2022.