As in C
we have srand(time(NULL)))
to ensure that the random number which will be generated on next call will be different than the random number generated for current call.
What i tried is this.
Random r=new Random();
for(int i=0;i<100;i++)
{
System.out.println(r.nextInt(1000));
}
But it may print similat number in consecutive iterations.
I want that it should print different numbers in consecutive iterations.
Are there any predefined methods to achieve this ?
Aucun commentaire:
Enregistrer un commentaire