public void randomGen(String[] x) {
int rand = rangen.nextInt(x.length-2);
JOptionPane.showMessageDialog(null, "Randomly chosen word is: " + x[rand]);
}
For anyone...
Type: Posts; User: Blackrabbitjack
public void randomGen(String[] x) {
int rand = rangen.nextInt(x.length-2);
JOptionPane.showMessageDialog(null, "Randomly chosen word is: " + x[rand]);
}
For anyone...
Would this be the proper way to use this utility?
public void randomGen(String[] x) {
Random rangen = new Random();
int rand = rangen.nextInt(x.length-1);
}
Not too sure if this is the right place to post this, so if it isn't, I apologize. Still figuring out my way around here.
Anyways, what is the best way to grab a random element from an array?...