// purpose: display some (pseudo) random numbers import java.util.*; public class RandomNumbers { public static final int BASE_256 = 256; // method main(): program starting point public static void main( String[] args ) { // get (pseudo) random number generator Random dice = new Random(); // throw dice without restriction int n1 = dice.nextInt(); int n2 = dice.nextInt(); int n3 = dice.nextInt(); System.out.println( "Random int values\n" + " " + n1 + " " + n2 + " " + n3 ); // throw dice with base restriction int n4 = dice.nextInt( BASE_256 ); // between 0 ... BASE-1 int n5 = dice.nextInt( BASE_256 ); // between 0 ... BASE-1 int n6 = dice.nextInt( BASE_256 ); // between 0 ... BASE-1 System.out.println( "Random base " + BASE_256 + " values\n" + " " + n4 + " " + n5 + " " + n6 ); } }