Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FindDuplicates2 {
- public static void main(String args[]) {
- int intArray[] = { 1, 2, 3, 4, 1 };
- findDuplicates(intArray);
- }
- public static void findDuplicates(int[] id) {
- System.out.println("Duplicate data: ");
- int count[] = new int[10];
- for (int i = 0; i < id.length; i++) {
- count[id[i]]++;
- if (count[id[i]] == 2) {
- System.out.println(id[i] + " ");
- }
- }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement