public class countryGroup {
public static void main(String[] args) {
Map<Integer,List<String>> Integer2Countrys = new HashMap<Integer,List<String>>();
List<String> ListCountry = new ArrayList<String>();
String country = "科特迪瓦,阿根廷,澳大利亚,塞尔维亚,荷兰,尼日利亚,日本,美国,中国," +
"新西兰,巴西,比利时,韩国,喀麦隆,洪都拉斯,意大利";
String[] countrys = country.split(",");
for (String string:countrys){
ListCountry.add(string);
}
for (int j = 0;j < 4;j++){
List<String> listcountrygroup = new ArrayList<String>();
for (int i = 0;i < 4;i++){
Random random = new Random();
int index = random.nextInt(ListCountry.size());
listcountrygroup.add(ListCountry.get(index));
ListCountry.remove(index);
}
Integer2Countrys.put(j+1,listcountrygroup);
}
for (Integer in : Integer2Countrys.keySet()){
System.out.println("第"+in+"组");
for (String str :Integer2Countrys.get(in)){
System.out.print(str+" ");
}
System.out.println();
}
}
}
网友评论