lundi 3 août 2015

Random element choice from String array

public class elements {
    public String[] elements = new String[118];
    public static String element_answer = ""
    elements[1] = "Hydrogen";
    elements[2] = "Helium";
    elements[3] = "Lithium";
    elements[4] = "Beryllium";
    elements[5] = "Boron";
}

I would like to randomly choose a element out of the array and assign the random choice to the variable element_answer. How could this be done?




Aucun commentaire:

Enregistrer un commentaire