-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathduplicate.java
More file actions
38 lines (37 loc) · 911 Bytes
/
duplicate.java
File metadata and controls
38 lines (37 loc) · 911 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
34
35
36
37
38
import java.util.Scanner;
class duplicate
{
void fcheck(int[] h)
{
System.out.println("The Duplicate elements in the array are : ");
for(int i=0;i<h.length;i++)
{
for(int j=i+1;j<h.length;j++)
{
if(h[i]==h[j])
System.out.print(h[i]+" ");
}
}
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the Array : ");
int r=sc.nextInt();
int[] a=new int[r];
duplicate d=new duplicate();
System.out.println("Enter "+r+" elements of Array : ");
for(int i = 0; i < r; i++)
{
System.out.println("Enter value of "+i+" index : ");
a[i]=sc.nextInt();
}
System.out.println("Printing Array : ");
for(int i=0;i < r;i++)
{
System.out.print(a[i]+" ");
}
System.out.println("\n");
d.fcheck(a);
}
}