就一步,很简单的
int[] temp = { 1, 2, 3, 4, 5, 123, 213, 123, 213, 21, 321321 };
int index = (int) (Math.random() * temp.length);// 随机数乘以数组长度,那么它的取值就在0-length之间
System.out.println(temp[index]);
int [] arr = {1,2,3,4};
//产生0-(arr.length-1)的整数值,也是数组的索引
int index=(int)(Math.random()*arr.length);
int rand = arr[index];
int[] s=new int[]{3,4,6,7,2};
Random rand=new Random();
int i=rand.nextInt(5);
System.out.println(s[i]);
Random rand = new Random();
int[] arr = {1,3,4,4,2,3};
int idx = rand.nextInt() * arr.length;
System.out.println(arr[idx]);