Hi,
I need to generate 10 random numbers without repeating the same number again. This is what I need to achieve: I have a set of 100 questions and each time the
test taker wants to take a test, the program should generate 10 questions from the available 100 question set. So, far i am able to generate random numbers without zero in the following way. But, how to avoid repeating the same number again? Any ideas or code will be appreciated.
import java.util.Random;
public class RandomTest
{
public static void main(
String args[])
{
Random generator = new Random();
int rnumber = generator.nextInt( 100 )+1;
// what is the code to eliminate the repetition...?
System.out.println("Random Number: "+ rnumber);
}
}
[ May 23, 2006: Message edited by: KiranKumar Gogineni ]