I tried the first time and found that this problem already occurred, so I wrote some extra code to mitigate this problem by adding if(m==0). But it does not seem to work, why?

```
public void merge(int A[], int m, int B[], int n) {
if(m==0){
A = B;
} else {
int[] result = new int[A.length];
int a=0;
int b=0;
int i=0;
while(a<m && b<n && i<(m+n)){
if(A[a]>B[b]){
result[i] = B[b];
i++;
b++;
} else {
result[i] = A[a];
i++;
a++;
}
}
if(i==(m+n))
A = result;
if(a==m){
while(i<(m+n)){
result[i] = B[b];
i++;
b++;
}
} else {
while(i<(m+n)){
result[i] = A[a];
i++;
a++;
}
}
A = result;
}
}
```

Thanks in advance.