forked from MLSA-MUET-SZAB-Club-Khairpur-Mir-s/Learn-to-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDuplicate.java
More file actions
23 lines (23 loc) · 726 Bytes
/
Duplicate.java
File metadata and controls
23 lines (23 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.Arrays;
import java.util.Scanner;
public class Duplicate {
public static void main(String[] args)
{
int my_array[] = new int[10];
Scanner sc = new Scanner(System.in);
System.out.println("enter the elements of an array:");
for(int i = 0; i < 10; i++) {
my_array[i] = sc.nextInt();
}
for (int i = 0; i < my_array.length-1; i++)
{
for (int j = i+1; j < my_array.length; j++)
{
if ((my_array[i] == my_array[j]) && (i != j))
{
System.out.println("Duplicate Element are: "+my_array[j]);
}
}
}
}
}