I'm doing a java program using random numbers.
I would like to avoid that each generated number, besides unique, is different from its index in array - for instance, the first number in array is not number 1, the second is not number 2, the third not number 3, and so one.
Can someone help ?
Thatīs my relevant code :


boolean isRepeated = false;
int [] rNums = new int [t1];

for (int x = 0 ; x < t1 ; x++)
{

do
{
isRepeated = false;
rNums [x] = (int) ((Math.random () * t1) + 1);
for (int y = 0 ; y < x ; y++)
{
if (rNums [x] == rNums [y])
{
isRepeated = true;
break;
}
}
}
while (isRepeated);