Finding Duplicates in Java
Use a Set.

private &lt;E&gt; boolean hasDuplicates(E[] array) {
    Set&lt;E&gt; set = new HashSet&lt;E&gt;();
    for(E e : array) {
        if (!set.add(e)) {
            return true;
        }
    }
    return false; 
}


The add() method of a set returns false if the object already exists in the set.