I made an array, but I confused as how to dispaly the array contents depanding on a random generator.
E.g. If there are four statements in my array, and when I run the program I get number 3, I would like it to link to a statment in the array.
E.g. its should print out: 3 - Get a job
I'm using this for the array:
String[] activityName = new String[5];
activityName[1] = "Go and Have Fun";
activityName[2] = "Hiya, Go Shooping";
activityName[3] = "Get a job";
activityName[4] = "Read a book";
And I am using this code to gerenate a random number:
Random generator = new Random();
int n=5;
int randomNumber = generator.nextInt( n );
System.out.println(randomNumber);
Plus I don't want to use a 0 in the generator.
Any help would be appreciated. Thank you.
n = 4
and then add one to randomNumber. – Sören Mar 2 '11 at 15:13