Check out example codes for "efficient generic duplicate finding class java". It will help you in understanding the concepts better.

Code Example 1

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);
            }
        }

    }

Learn ReactJs, React Native from akashmittal.com