Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

efficient generic duplicate finding class java

public static <T extends Comparable<T>> void getDuplicates(T[] array) {
        Set<T> dupes = new HashSet<T>();
        for (T i : array) {
            if (!dupes.add(i)) {
                System.out.println("Duplicate element in array is : " + i);
            }
        }

    }
Source by www.java67.com #
 
PREVIOUS NEXT
Tagged: #efficient #generic #duplicate #finding #class #java
ADD COMMENT
Topic
Name
6+9 =