第1个回答 2011-05-18
import java.util.Random;
public class Test {
public static void main(String[] args) {
String str[] ={"java","中随机应用","已知数组","怎么从中随机抽几个元素出来","组成一句话 "};
String str1[] = new String[str.length];
Random r = new Random();
int a=0;
for(int i=0;i<str.length;i++){
str1[a]= str[r.nextInt(5)];
System.out.print(str1[a]+" ");
a++;
}
}
}本回答被提问者采纳