W M W M - 6 months ago 25
Java Question

A random generator for array indices..?

i know this for normal integers, but is there for such a thing as indices

Random Dice = new Random();
int n = Dice.nextInt(6);
System.out.println(n);

Answer

What do you mean? Array indices are normal numbers, so you can easily do

String names[] = { "One", "Two", "Three", "Four", "Five", "Six" };
Random Dice = new Random(); 
int n = Dice.nextInt(6); 
System.out.println(names[n]);

Or do you mean a random Iterator class? Google is your friend here, this is the first hit I get.