I need to implement a structure in Java that is a key-value list (of types Integer-String) and I want to shuffle it.
Basically, I would like to do something like that.>
Create a Pair
class, that holds both the Integer
and the String
and then add multiple Pair
objects to a List, which will be shuffled.
public class Pair {
private Integer integer;
private String string;
//accessors
}
Then:
List list = new ArrayList();
//...add some Pair objects to the list
Collections.shuffle(list);