I'm trying to make an array of random colors from another array.
String [] colors = new String[6];
colors[0] = "red";
colors[1] = "green";
colors[2] = "blue";
colors[3] = "yellow";
colors[4] = "purple";
colors[5] = "orange";
That's my array as of now. I want to make a new array with just 4 of those colors without duplicates.
So far I know how to make an array of randoms; however, I don't know how to take care of duplicates efficiently.
LinkedList, and take (remove) from a random index between 0 andsize()HashSetuntil the size of theHashSetis 4 would be by approach