Simple algorithm:
- create an array containing numbers from 0 to 10
- shuffle
- iterate over that array and retrieve the corresponding index in the initial collection
In Java:
public static void main(String[] args) throws Exception {
List<Integer> random = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
Collections.shuffle(random);
List<String> someList = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k");
for (int i : random) {
System.out.print(someList.get(i));
}
}
outputs:
ihfejkcadbg
EDIT
Now that I reread it, you could also simply shuffle the initial collection and loop:
public static void main(String[] args) throws Exception {
List<String> someList = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j");
//make a copy if you want the initial collection intact
List<String> random = new ArrayList<> (someList);
Collections.shuffle(random);
for (String s : random) {
System.out.print(s);
}
}