Check for duplicates while populating an array
I have an array that I populate with 6 randomly generated numbers. First it generates a random number between 1 and 49 and then checks it against the numbers in the array. If it finds a duplicate it should generate a random number again and then perform the check once again. If there are no duplicates then the number is added to the array. Here's the code: public void populateArray() { for(int i = 0; i < numberLine.length; i++) { randomNumber = 1 + randomGen.nextInt(49); for(int j = 0; j < i; j++) { if (numberLine[j] == randomNumber) { i--; } else { continue; } } if(i >= 0) { numberLine[i] =