/* Punters Lounge JAVA programming course * * Lesson4.java * * Author : Erik Datapunter * Date : 28/apr/2004 * * Displays a random number. * */ // import the java.util.* classes containing the Random class import java.util.*; public class Lesson4 { public static void main(String[ ] arguments) { // variable mynumber int mynumber = 0; /* new Random object called numberx, initialised using the computers clock * using the computers clock results in a different random number being generated * each time the program is run. A fixed value will generate random numbers but always * the same random numbers. */ Random numberx = new Random(System.currentTimeMillis()); // generate a new random number using the nextInt() method mynumber = numberx.nextInt(); // display the random generated number System.out.println(mynumber); } }