forked from Annex5061/java-algorithms
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDuplicatefind.java
More file actions
Latest commit
33 lines (14 loc) · 563 Bytes
/
Copy pathDuplicatefind.java
File metadata and controls
33 lines (14 loc) · 563 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
publicclassDuplicateElement {
publicstaticvoidmain(String[] args) {
//Initialize array
int [] arr = newint [] {1, 2, 3, 4, 2, 7, 8, 8, 3};
System.out.println("Duplicate elements in given array: ");
//Searches for duplicate element
for(inti = 0; i < arr.length; i++) {
for(intj = i + 1; j < arr.length; j++) {
if(arr[i] == arr[j])
System.out.println(arr[j]);
}
}
}
}