1import java.util.Random;
2public class RandomSelect {
3
4 public static void main (String [] args) {
5
6 String [] arr = {"A", "B", "C", "D"};
7 Random random = new Random();
8
9 // randomly selects an index from the arr
10 int select = random.nextInt(arr.length);
11
12 // prints out the value at the randomly selected index
13 System.out.println("Random String selected: " + arr[select]);
14 }
15}
1String[] s = {"your", "array", "of", "strings"};
2
3Random ran = new Random();
4String s_ran = s[ran.nextInt(s.length)];