第2个回答 2010-11-01
import java.util.Random;
import java.util.Vector;
public class test{
/**
* @param args
*/
public static void main(String[] args) {
String[] strs = { "a", "b", "c", "d"};
int strsLength = strs.length;
Vector<Integer> v = new Vector<Integer>();
Random r = new Random();
boolean flag = true;
while (flag) {
int i = r.nextInt(strsLength);
if (!v.contains(i))
v.add(i);
if (v.size() == strsLength)
flag = false;
}
for (int i = 0; i < strsLength; i++) {
System.out.println(strs[v.get(i)]);
}
}
}本回答被提问者采纳