2020
10-10
10-10
如何基于java随机获取不重复数值
假如我有一个数组:ArrayList<Integer>mArrayList=newArrayList<Integer>();mArrayList.add(0);mArrayList.add(1);mArrayList.add(2);mArrayList.add(3);我需要从中随机抽取2个数不能重复抽取,我就会用这个方法publicvoidgetValue(ArrayList<Integer>mArrayList){RandommRandom=newRandom();inta=mRandom.nextInt(mArrayList.size());intvalue=mArrayList.get(a);System.out.println(value+"...
继续阅读 >