hey .. i was told to make an void mergeArrays(int[] ar1 , int[] ar2);
i made it in this way ..
Code:
int[] ar1 = {1,2,3,4}
int[] ar2 = {5,6,7,8}
mine code :
Code:
public static void mergeArray(int[] ar1 , int[] ar2) {
int[] res = new int[ar1.length+ar2.length];
int counter = 0;
for(int a = 0; a<ar1.length; a++)
{
res[a] = ar1[a];
counter++;
}
for(int b = 0; b<ar2.length; b++)
{
res[counter++] = ar2[b];
}
for(int temp = 0; temp<res.length;temp++)
{
System.out.print(res[temp]+" ");
}
}
out put 12345678.
all working .. then i was told that i can do it with 1 LOOP . curios if it is possible ?
thanks for helping !