Hi I am making a program that generates 100 Random numbers between 0-999 also it heads all the numbers below 100 with 0's eg 099 and 003. I also need to make sure the program generates all unique numbers(no numbers can be the same , if a number generated is the same it needs to create a different number until its different. ive generated the number creater and got all numbers to be headed with 0's but im really stuck on the generating all unique numbers part. Can anyone help please? heres my code :
import java.util.Random;
public class Random100
{
public static void main(String args[])
{
int x;
int [] Arrayofrandom = new int [100];
Random RandomGenerated = new Random();
for (x = 0; x<Arrayofrandom.length;x++)
{
Arrayofrandom[x] = RandomGenerated.nextInt(999);
}
for (x=0; x<100;x++)
{
if(Arrayofrandom[x]<10)
System.out.print("00"+Arrayofrandom[x]+"\t");
else if(Arrayofrandom[x]<100&&Arrayofrandom[x]>9)
System.out.print("0"+Arrayofrandom[x]+"\t");
else
System.out.print(Arrayofrandom[x]+"\t");
}
}
}