1 2 3 4 5 6 7 8 9 10 11 12 13 14
| public class RandomGroup { public static void main(String[] args) { String[] s1 = {"Marin", "Jade", "Rorschach", "Kinson", "Eric", "GlenZ", "GlenY", "Billy", "Mark", "Kyrie", "Berlin", "Chris", "Betterman", "Linke", "Aplhe", "Andy", "Grace", "Yetta", "Mickey", "Sunny"}; Arrays.sort(s1); ArrayList<String> lists = new ArrayList<String>(Arrays.asList(s1)); Collections.shuffle(lists, new Random(20210304)); for (int i = 0; i < lists.size() - 1; i++) { if (i % 2 == 0) { System.out.println(lists.get(i) + " 和 " + lists.get(i + 1)); } } } }
|