I was wondering how do i go about generating unique random numbers?
i want to generate numbers between 0-9 randomly. I dont want to repeat the numbers.Then that no: should display on the buttons.ie there are 9 buttons. first randomly generated number should display on the first button & 2nd no: should display on 2nd button. & so on for example I have the numbers 9371482065 then 9 should display on the first button ,3 should display on 2nd button ....
But the following code i'm having is repeating some numbers...can any one help me in solving...please.....


Random rgen = new Random(); // Random number generator
int[] cards = new int[10];

// --- Initialize the array to the ints 0-51
for (int i=0; i<10; i++) {
cards[i] = i;

// --- Shuffle by exchanging each element randomly
for (int i=0; i<10; i++) {
int randomPosition = rgen.nextInt(10);
System.out.println(" randomPosition " + randomPosition);
int temp = cards[i];
System.out.println(" temp" + temp);
cards[i] = cards[randomPosition];
cards[randomPosition] = temp;

System.out.println(" Random Number" + cards[randomPosition]);