I'm trying to get this as the output:
How many colours do you need?
user inputs a number say 3
Result:
gets 3 RANDOM colours from a list of choices
My problem is that yes the user gets 3 random colours but some of them are repeated. I end up getting,
red
blue
red
I've tried using a set but I don't know how to write it in a way that it'll pick out 3 shuffled items in said set.
How I'm selecting random colors:
colours obj = new colours();
for (int i = 0; i < X; i++) {
System.out.println(obj.randommm(list));
}
public String randommm(List<String> list) {
int index = random.nextInt(list.size()); return list.get(index);
}