Hi

I have created an array of random numbers but I need to stop duplicate numbers being added to the array so I have added the boolean 'fresh'. however, I somehow need to tell my 'fresh' to only check the number of elements added to the array so far and I am embarrassed to say i can't figure this out as I am sure it is easy.

I have been searching books and the internet but just cannot figure it out. :rolleyes:

Any help in the right direction would be really appreciated

my code is:

```
int amount = 7; // number of integers needed to generate
int[] nums = new int[amount];
int i;
// method for searching the array for duplicate numbers
boolean fresh (int [] nums, int val){
for (int i = 0; i < amount; i++){
if (nums[i] == val) return true;
}
{
return false;
}
}// end fresh method
//method to generate random numbers to insert into the tree
public void randomNumber()
{
do
{
for (int i=0; i<amount; i++) {
nums[i] = (int) Math.floor(Math.random() * 100);
nums[i] = nums[i] -50;
System.out.println("random is " + nums[i]);
}
}
while(!(fresh(nums,i)));
}// end of randomNumber method
```