Skip to content

Commit 2c2e5e5

Browse files
main
1 parent 16c8ee4 commit 2c2e5e5

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

3.Array/ClassCodes/merge.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
3+
4+
public class merge {
5+
public static void main(String[] args) {
6+
int a1[] = {2,1,4,5};
7+
int a2[]= {1,5,6,7};
8+
9+
int ans[] = new int[a1.length+a2.length];
10+
11+
12+
for(int i=0;i<(a1.length+a2.length);i++){
13+
if(i<a1.length){
14+
ans[i] = a1[i];
15+
}
16+
else{
17+
ans[i] = a2[i-a1.length];
18+
}
19+
}
20+
21+
for(int i=0;i<ans.length;i++){
22+
System.out.print(ans[i]+" ");
23+
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)