球队分组


public class countryGroup {
    public static void main(String[] args) {
        Map> Integer2Countrys = new HashMap>();
        List ListCountry = new ArrayList();
        String country = "科特迪瓦,阿根廷,澳大利亚,塞尔维亚,荷兰,尼日利亚,日本,美国,中国," +
                "新西兰,巴西,比利时,韩国,喀麦隆,洪都拉斯,意大利";
        String[] countrys = country.split(",");
        for (String string:countrys){
            ListCountry.add(string);
        }
        for (int j = 0;j < 4;j++){
            List listcountrygroup = new ArrayList();
            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();
        }
    }
}

你可能感兴趣的:(球队分组)