Objective
In the paper, you need to be a sentence of words, a word in the characters, multiple-choice questions in the answer to create a random sequence, the following I will be abstracted into a tool class, convenient for everyone to reuse later.
Sample code
public static <V> Boolean isempty (arraylist<v> sourceList) {return
(sourceList = = NULL | | sourcelist.siz E () = = 0);
}
/** * ArrayList * * * * public
static <V> arraylist<v> randomlist (arraylist<v> SourceList) {
if (IsEmpty (sourceList)) {return
sourceList;
}
arraylist<v> randomlist = new arraylist<v> (Sourcelist.size ());
do{
int randomindex = Math.Abs (new Random (). Nextint (Sourcelist.size ()));
Randomlist.add (Sourcelist.remove (Randomindex));
} while (Sourcelist.size () > 0);
return randomlist;
}
Summarize
The above is the Java scrambling ArrayList to generate a random list of all the content, I hope for the future use of Java to provide convenience. If you have questions, you can exchange messages.