Check out example codes for "generate random number in java within a range without repeating with android studio". It will help you in understanding the concepts better.
Code Example 1
public void NextRandom(View view) // button clicked function
{
int previousIndex = index;
index = rand.nextInt(array.size());
while (index == previousIndex)
{
index = rand.nextInt(array.size());
}
}
Learn ReactJs, React Native from akashmittal.com