用hashSet求10 0到30之间的无重复随机数
public static void main (String args[]) {
Random rand=new Random();
Set<Integer> intset=new HashSet<Integer>();
for (int i = 0; i < 10; i++) {
intset.add(rand.nextInt(30));
System.out.println(intset);
}
for(int i=0;i<30;i++){
int position=arrs.length-i-1;
int j=new Random().nextInt(position+1);
if(j!=position){
int tmp=arrs[j];
arrs[j]=arrs[position];
arrs[position]=tmp;
}