1import java.util.Random;
2
3public class RandomStringFromArray
4{
5 public static void main(String[] args)
6 {
7 String[] arr={"1", "2", "3", "4", "5"};
8 Random r=new Random();
9 int randomNumber=r.nextInt(arr.length);
10 System.out.println(arr[randomNumber]);
11 }
12}
1public static int getRandom(int[] array) {
2 int rnd = new Random().nextInt(array.length);
3 return array[rnd];
4}