i have an array it fill with some values(int).i want to pick one of this elements up randomly and use it value as a index of another array.what should i do?
int value[] = {1,2,3,8,9,40,0,5,...};
int value-2[] = {0,1,2};
Random rand = new Random();
System.out.print(value-2[rand.nextint(value.lenght)]);
Create arrays:
Generate a random index between 0 and array.length:
Get value from first array:
Get value from second array: