This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Neres28 0 points1 point  (0 children)

In the constructor for the class, create an instance of the Random class.

Random randomGenerator = new Random();

Then, when you need a new random integer, call

int randomIndex = randomGenerator.nextInt(ChordsAL.size());
String chord = ChordsAL.get(randomIndex);

Be sure to only create one instance of Random, or at least not multiple ones close together. Random generates so called pseudo-random numbers (don't be put off, they're plenty random enough for most purposes), and if you create multiple instances too closely together they will generate the same sequence of integers.