package patten;
public class DuplicateValueinArray {
public static void main(String[] args) {
int a[]= {1,2,3,4,5,6,7,1,2,3};
// how to find the duplicate in this Array .
for(int i=0;i<a.length;i++)
{
int key =a[i];
int count=1;
for(int j=1+i;j<a.length;j++)
{
if( key==a[j])
{
a[j]= '';
count++;
}
}
if(key!='')
{
System.out.println(key+" duplicate"+ count);
}
}
}
}
OUTPUT:-
1 duplicate2
2 duplicate2
3 duplicate2
4 duplicate1
5 duplicate1
6 duplicate1
7 duplicate1
Top comments (0)