-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoveDup.java
More file actions
42 lines (38 loc) · 788 Bytes
/
RemoveDup.java
File metadata and controls
42 lines (38 loc) · 788 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
39
40
41
42
package strings;
public class RemoveDup {
public static void main(String[] args) {
String[] a = new String[] {"one","two","three","eight","one"};
String[] b = new String[] {"five","four","two","five","eight","six","seven"};
int l1 = a.length;
int l2 = b.length;
int k=0,flag=0,l,m;
String[] c = new String[l1+l2];
for(int i=0;i<l1;i++) {
for(l=0;l<i;l++) {
if(a[i]==a[l])
break;
}
if(l==i)
c[k++] = a[i];
}
for(int i=0;i<l2;i++) {
for(int j=0;j<l1;j++) {
if(b[i]==a[j]) {
flag=1;
break;
}
}
if(flag==0){
for(m=0;m<i;m++) {
if(b[i]==b[m])
break;
}
if(m==i)
c[k++]=b[i];
}
flag=0;
}
for(int i=0;i<k;i++)
System.out.println(c[i]);
}
}