I generated 1-10 random numbers and stored it in an array. My question is how I'm going to check if the new generated number is not the same as the previous number stored. so here's my code:
CODE:
int min=1;
int max=10;
int y=0;
Random rand = new Random();
for(int count=0;count<1;count++){
int randomNum = rand.nextInt((max - min) + 1) + min;
arr[count] = randomNum;
}
System.out.println(arr[0]);//for checking
System.out.println(randomNum);//for checking
Aucun commentaire:
Enregistrer un commentaire