String[] randomArray = new String[]{"张三","李四","王五","赵六","孙七","周八","吴九"}; //生成随机数组索引 int index = (int)(Math.random()*randomArray.length); System.out.println("本次随机到:"+randomArray[index]);
//将所有的人员生成数组,然后获取数组的长度,最后再随机下标,根据下标获得的就是具体的人。
时间: 2024-10-23 06:07:54