String[] farther={1,2,3,4,5,6,7,8,9,0,................}; String[] son; Random r=new Random(); int j; int k=0; int record; int flag;//设置你想要从父数组中取出多少个随机值 for(int i=farther.length;i>1;i--){ j=r.nextInt(i);//父数组中随机一个索引son[k++]=farther[j];//将这个数放入子数组record=farther[j];//将已放入子数组的值放到父数组后面,防止子数组值重复 farther[j]=farther[i]; farther[i]=record;if(k==flag){ break; } }
for(int i=0;i<s.length;i++){
if(s[i]==j)
return true;
else return false;
}
String[] farther={1,2,3,4,5,6,7,8,9,0,................};
String[] son;
Random r=new Random();
int j;
int k=0;
int record;
int flag;//设置你想要从父数组中取出多少个随机值
for(int i=farther.length;i>1;i--){
j=r.nextInt(i);//父数组中随机一个索引son[k++]=farther[j];//将这个数放入子数组record=farther[j];//将已放入子数组的值放到父数组后面,防止子数组值重复
farther[j]=farther[i];
farther[i]=record;if(k==flag){
break;
}
}