SP
2012-02-14 13:46:17 UTC
public class RandomGenerator {
public static void main(String[] args) {
String[] array = {"asd","asdf","asdfg","asdfgh","asdfghj"};
String results = array[Math.random()*(array.length-1)];
}
}
Can I have three arrays, each of which has a random string picked out of it? What parts do I have to change to make it so the Math.random functions do not interfere with each other? Would this be the way to do that?
public class RandomGenerator {
public static void main(String[] args) {
String[] array = {"asd","asdf","asdfg","asdfgh","asdfghj"};
String results = array[Math.random()*(array.length-1)];
String[] array1 = {"asd","asdf","asdfg","asdfgh","asdfghj"};
String results = array1[Math.random()*(array1.length-1)];
String[] array2 = {"asd","asdf","asdfg","asdfgh","asdfghj"};
String results = array2[Math.random()*(array2.length-1)];
}
}
Also, can I make them all display at once in a text box in order with the click of a button? I'm pretty new to this, so thank you for your help.