0
You will only be able to do this for ordered collections like lists, and not sets which are unordered. List member function: add(int index, E element) Inserts the specified element at the specified position in this list (optional operation). Then use: import java.util.Random; Random rand = new Random(); int n = rand.nextInt(x); To get a random index for the list's add() function, ensuring you insert with an index that is in range (i.e. between 0 and length of list).
23rd Apr 2018, 1:22 AM
Emma