import java.util.Random; // import the random class
private static string pickRandomString(String[] words) // create a method called "pickRandomString" (takes a String array called "words")
{
Random rand = new Random(); // create a new instance of the random class, this will be used to generate a random integer
return words[rand.nextInt(words.length)]; // returns the value of the next integer from the random number generator (the integer will be between 0 and the length of the words array)
}
PICHU.
import java.util.Random; // import the random class
private static string pickRandomString(String[] words) // create a method called "pickRandomString" (takes a String array called "words")
{
Random rand = new Random(); // create a new instance of the random class, this will be used to generate a random integer
return words[rand.nextInt(words.length)]; // returns the value of the next integer from the random number generator (the integer will be between 0 and the length of the words array)
}
Copyright © 2026, NextGenUpdate.
All Rights Reserved.