I have an int array and I have assigned a value from it with a random index to a int variable. I wanted to know if there is a way to check the index from the array that it came from from the variable it was assigned.
Random rand = new Random();
private int[] cards = {2, 3, 4, 5, 6, 7, 8, 9, 10};
int a = cards[rand.nextInt(8)];
so I assigned a value from the array to variable a but I want to know if there is a way to check the variable a to see what the index was it came from
rand.nextInt(8)in an own variable, then you know your index ... quite obvious, right?