Java programming: give you a list of classes and divide them into six groups at random.
Note: The target list file should be written in the directory at the same level as the package name, record src, right-click, create a file, and copy the list to this file, the program can access the content of this list according to some policies.
ArrayList is a List and data is ordered. The HashSet element can be a Set. The data has no sequence and no repeated elements. The element search speed is fast.
Random package grouping; import java. util. arrayList; import java. util. hashSet; import java. util. list; import java. util. imports; import java. util. set; public class Test {public static void main (String [] args) {List
Zu = new ArrayList
(); Using SC = new using (Test. class. getClassLoader (). getResourceAsStream ("table.txt"); while (SC. hasNextLine () {String eachOne = SC. nextLine (); if (eachOne! = Null & eachOne. trim (). length ()> 0) {zu. add (eachOne); // add to the List set // System. out. print (eachOne + "\ t") ;}// the list can be repeated in an ordered manner. // The set can be unordered and cannot be repeated. (This is recommended for this question, because once many people with the same name are recorded in your table, they can ignore duplicate names for you, but they are people with the same name.) Set
S1 = new HashSet
(); // List
S1 = new ArrayList
(); Int count = 0; // while (true) {if (zu. size () = 0) {break;} int index = (int) (Math. random () * zu. size (); String n = zu. get (index); if (s1.add (n) // Add the corresponding string (name) to the set object {System. out. print (n + "\ t"); zu. remove (n); // count ++; if (count % 7 = 0) // controls the line feed System. out. println ();}}}}