I am filling an array with random integers 1 - 10, however while I'm doing this I need to check to see if the Integer is already in the array. I have no problem filling the array with the integers but my code to check for duplicate integers is not working properly.
package arrayPackage;
import java.util.Arrays;
import java.util.Random;
public class BruteForce
{
//declare an integer array with 10 numbers.
int[] array = new int[10];
Random randomInt = new Random(); //random number generator
public void shuffle()
{
//int prevInt=0;
for(int i = 0; i < array.length; i++) //for each integer in the array pick a random integer and place in array
{
int temp = 1 + randomInt.nextInt(array.length);
for(int j = i; j < array.length; j++)
{
if(temp != array[j] && temp!= array[i])
{
array[i] = temp;
}
}
}
}
public void displayArray()
{
System.out.println(Arrays.toString(array));
}
}