This program is supposed to make 10 unique #s in an array, it outputs correctly, but it is stuck in the while loop. hHow can I get out?
import java.util.Random;
public class Extra {
public static void main(String[] args) {
// Variables
int rand;
int [] unique = new int [11];
boolean [] check = new boolean [11];
Random generator = new Random();
// Welcome
System.out.print("Here are your ten unique array values: ");
// Set Arrays
for(int counti = 0; counti < unique.length; counti++) {
check[counti] = false;
}
// Set Array
for(int count = 0; count < unique.length; count++) {
if(check[unique[count]] == false){
check[unique[count]] = true;
System.out.print(unique[count] + " ");
}
else{
while(check[unique[count]] == true) {
unique[count] = generator.nextInt(10) + 1;
if(check[unique[count]] == false){
check[unique[count]] = true;
System.out.print(unique[count] + " ");
}
if(count > 2){
break;
}
}
}
}
}
/**
Here are your ten unique array values: 437521689
*/