import java.util.*;
public class DuplicateElements {
public static void main(String args[]) {
int count, i;
int[] intArray = { 1, 2, 3, 4, 5, 6, 7, 7, 8, 8, 8, 9, 9, 9 };
Map map = new HashMap();
// Count frequency of elements in array
for (Integer val : intArray) {
if (map.containsKey(val)) {
// Increment counter
map.put(val, map.get(val) + 1);
} else {
map.put(val, 1);
}
}
// Check for duplicate element
System.out.println("Duplicate Elements
");
Set keys = map.keySet();
for (Integer key : keys) {
if (map.get(key) > 1) {
System.out.print(key + " ");
}
}
}
}