Discarding array item once used
<p>How can I make sure that a random number is only generated once?</p>

<p>For example:</p>

<pre><code>for(int i = 0; i&lt;len; i++)
    {
        while (rands.contains(rand = r.nextInt(len-2)+1));
        rands.add(rand);
        System.out.print ("Rand ___ " + rand + "___");
    }
</code></pre>

<p>How can I make sure that if the number 2 is generated from rand, it wont be generated again?</p>

<p>I apologise if i am not making myself clear enough. Please comment if you require any more information.</p>

<p>Thanks.</p>
