Android pick 2 random int from a specified range
<p>In my Android app, I need to pick two random integers from a specified range. The below code works, but it's not really picking a random integer, it's shuffling the ints. And the thing that bugs me is that I have to specify the max int as one less than is actually the max value because of the <code>randomNum2= (int)it.next();</code> bit in the code. If I put the correct number (currently 127) as the max, then I get the error <code>java.util.NoSuchElementException</code> because it's looking for 128 as the next iteration. Before I was using <code>rand = new Random();
    randomNum1 = rand.nextInt(max - min + 1) + min;
    randomNum2 = rand.nextInt(max - min + 1) + min;</code> But the problem there is the two random ints may end up being the same, and I need them to be unique. So can anyone suggest a better method for getting TWO random numbers from a min/max interger range? Here's my code:</p>

<pre><code>    int min = 1;
int max = 126;
int randomNum1;
int randomNum2;
List&lt;Integer&gt; choicesL;

public void randomTwo() {
    choicesL = new LinkedList&lt;Integer&gt;();
    for (int i = min; i &lt;= max; i++) {
        choicesL.add(i);
    }
    Collections.shuffle(choicesL);
    Iterator&lt;Integer&gt; it = choicesL.iterator();
    while (it.hasNext())
    {
        randomNum1= (int)it.next();
        randomNum2= (int)it.next();

    }

}
</code></pre>
