random words
Sun May 21 2023 11:08:09 GMT+0000 (Coordinated Universal Time)
Saved by
@gokulz
/**
* Function Name: randomWord
*
* @return String words[index];
*
* Inside the Function
* 1. numWord variables contains words length
* 2. Math.random method to get a random numbers
* 3. multiply both to get random index
*/
public static String randomWord(){
int numWords = words.length;
double randomWord = Math.random();
int randomIndex = (int)(randomWord *numWords);
return words[randomIndex];
}
content_copyCOPY
Comments