Random r = new Random();
System.out.println(b[r.nextInt(3)]);r.nextInt(3);就是随机取得0 1 2这三个数中的其中一个,然后当做你数组的下标,就随机抽取了
Random r = new Random();
System.out.println(b[r.nextInt(3)]);r.nextInt(3);就是随机取得0 1 2这三个数中的其中一个,然后当做你数组的下标,就随机抽取了
Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.