Java Program to print the duplicate elements of an array
/*
Java Program to print the duplicate elements of an array
*/
import java.util.*;
class Twentythree
{
public static void main(String arg[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter Array Size : ");
int n = in.nextInt();
int arr[] = new int[n];
for(int i=0; i<n; i++)
{
System.out.print("Enter Number of Arr[" + i + "] : ");
arr[i] = in.nextInt();
}
for(int i=0; i<n; i++)
{
System.out.println("Arr[" + i + "] Is : " + arr[i]);
}
System.out.print("\nDuplicate Value Is : ");
for(int i=0; i<n; i++)
{
for(int j=i+1; j<n; j++)
{
if(arr[i]==arr[j])
{
System.out.print(arr[j] + ",");
}
}
}
System.out.print("\n");
}
}
More Information on our channel Programmer Community
please like , share and subscribe to get notifications of new videos....
To understand this program video will coming soon on our you tube channel
Comments
Post a Comment