Better way to generate unique random numbers in Java
<p>I need unique random ints in specified range. I use this approch:</p>

<pre><code>class Main
{
static final int RANGE = 100;

static int uniqueGenerator(int range_, boolean boolArr_[], Random rand_)
{
    int tmpVar = rand_.nextInt(range_);
    while (boolArr_[tmpVar] == true)
    {
        tmpVar = rand.nextInt(range_);
    }
    boolArr_[tmpVar] = true;
    return tmpVar;
}

public static void main(String[] args)
{
    Random rand = new Random();  
    boolean boolArr[] = new boolean[RANGE];
    Arrays.fill(boolArr, false);
    int ceiling = 10;
    int tmp = Main.uniqueGenerator(ceiling, boolArr, rand);
    System.out.println(tmp); =&gt; 5
    ceiling = 20;
tmp = Main.uniqueGenerator(ceiling, boolArr);
    System.out.println(tmp); =&gt; 17

}
}
</code></pre>

<p>It seems to be cumbersome. Maybe someone knows better approach?
EDIT: I use it in game code, so I need most efficient solution. Answers below suggest initializing new list, shuffling it => too resource consuming/need to generate new list every time when need to change range.</p>
