String[] randomArray = new String[]{"张三","李四","王五","赵六","孙七","周八","吴九"};
//生成随机数组索引
int index = (int)(Math.random()*randomArray.length);
System.out.println("本次随机到:"+randomArray[index]);
//将所有的人员生成数组,然后获取数组的长度,最后再随机下标,根据下标获得的就是具体的人。
转载于:https://blog.51cto.com/mazongfei/1906998