Grabbing random object from ArrayList is not random.
- by Isai
I am creating a method where if you pass in a parameter of type Random, then it will return a random object. Here is basically what I am trying to do:
public T choose(Random r) {
int randomInt = r.nextInt(randomList.size()); // randomList is just a instance variable
return randomList.get(randomInt);
}
The random list has this the…