Skip to content Skip to sidebar Skip to footer

Shuffling An Array Of Strings

I have set up a technique for shuffling Strings. int Random = (int) (Math.random() *4); I am not sure how I can get this to work with my String Array. I would like to randomi

Solution 1:

Check it

List<String> arr = Arrays.asList(imageThumbUrlsRandom);
Collections.shuffle(arr);
arr.toArray(imageThumbUrlsRandom);

And if you have your own RNG (or if you just want to specify a seed for a default one), you can pass it:

longseed=0xDEADBEEFL;
Randomrng=newRandom(seed);
List<String> arr = Arrays.asList(imageThumbUrlsRandom);
Collections.shuffle(arr, rng);
arr.toArray(imageThumbUrlsRandom);

Post a Comment for "Shuffling An Array Of Strings"