@@ -0,0 +1,560 @@
+package com.doctor.interview;%0A%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0A/**%0A * @see http://howtodoinjava.com/2015/03/04/find-duplicate-elements-in-an-array/%0A * %0A * @author doctor%0A *%0A * @time 2015%E5%B9%B45%E6%9C%882%E6%97%A5 %E4%B8%8A%E5%8D%8812:28:48%0A */%0Apublic class FindDuplicateElementsInAnArray %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09int%5B%5D array = %7B 1, 1, 2, 3, 4, 5, 6, 7, 8, 8 %7D;%0A%09%09Set%3CInteger%3E set = new HashSet%3C%3E();%0A%09%09for (int i = 0; i %3C array.length; i++) %7B%0A%09%09%09if (set.add(array%5Bi%5D) == false) %7B%0A%09%09%09%09System.out.println(%22Duplicate element found :%22 + array%5Bi%5D);%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

Find duplicate elements in an array