Non-Repeating Random Integers
I trying to make a list of 100 random numbers between 1 and 100 without any of them repeating. I built a boolean array and assigned the value true as each number was chosen inside a for-if loop.
The problem is that sometimes it takes about 600-800 iterations.
I was wondering if there was a better way to do this. Is there a method to do this already in Java that isn't as intensive?
I was thinking of making a list of 100 random numbers and then just ranking them and using the ranking as my 100 random numbers since I wouldn't have any repeating. I'm not sure if there is a way to rank a list of 100 numbers though or how intensive it would be.