mercredi 19 juillet 2017

Java: How to build an array of a given length with random index's taken from another array

I'm working on my own little project and I'm having a small issue.

Lets say I have a String array {"Green","Blue"}.

I want to be able to make a new array of some length, lets say for example 100, with each index 0-100 being randomly selected from the above String array so I should get:

{"Green","Green","Blue","Green","Blue","Blue","Green" ...... "Blue"}

It seems really simple I don't know why I'm having a hard time. If anyone could help me solve this in a very simple way, I am trying to test my logic not my knowledge of code. Thanks!




Aucun commentaire:

Enregistrer un commentaire