Question: hey guys,
 right i have an array of 50 random integers and i have to check if any of them are the same,
here is my code so far it only checks ajacent indexs

```
for (int i =0; i < 50; i++)
{
    System.out.print("Student" + i + ": "   );

    customers[i] = (int)((Math.random()*10000)%10+1);
    System.out.print(" " +customers[i]+ "\n");

    if( duplicate == customers[i])
    {
        System.out.println("yup");
    }
    duplicate = customers[i];
}

```

Answer: 
I think, if you have to just use if/for functions, you have to make two loops:

```
for (int i =0; i < 50; i++)
{
    customers[i] = (int)((Math.random()*10000)%10+1);

    for ( int j = 0; j < i; j++)
    {
        if( customers[j] == customers[i])
        {
            // duplicated entry. do what you want
            System.out.println("yup");
        }
    }
}

```
You could use `Arrays.sort` (see more at <http://www.exampledepot.com/egs/java.util/coll_SortArray.html>) to sort your data, and then check for duplicates.