package com.arc.test;
import java.util.Random;
public class TestRandom {
public int random(int i){
return i = new Random().nextInt(6);
}
/** * @param args */
public static void main(String[] args) {
// 写一个方法将数组{3,6,a,顺序,随即,pailie}中的元素随机排列并返回
String s[] = {"3","6","a","顺序","随即","pailie"};
Random ran = new Random();
for(int i=s.length-1;i>=0;i--){
int n = ran.nextInt(i+1);
String temp = s[n];
s[n]=s[i];
s[i]=temp;
System.out.println(s[i]);
}
}
}
import java.util.Random;
public class TestRandom {
public int random(int i){
return i = new Random().nextInt(6);
}
/** * @param args */
public static void main(String[] args) {
// 写一个方法将数组{3,6,a,顺序,随即,pailie}中的元素随机排列并返回
String s[] = {"3","6","a","顺序","随即","pailie"};
Random ran = new Random();
for(int i=s.length-1;i>=0;i--){
int n = ran.nextInt(i+1);
String temp = s[n];
s[n]=s[i];
s[i]=temp;
System.out.println(s[i]);
}
}
}