public class test{
//my words
private static String[] words = {"apple", "banana", "cat", "dog", "elf", "frog" };
public static void main(String[] args) {
int randomWord = (int) (Random() * words.length);
System.out.println(randomWord);
}//end string
}//end class
I just start a project and all i want to know is how to return a specific word while still having it be random. At the moment it just prints/returns the number of the position in the string. For example i want it to return "cat" and if it does the print "" for every letter in cat. I already have the code to print the "" for every letter i just need to get the word back instead of an int.
Aucun commentaire:
Enregistrer un commentaire