15,942,580 members
See more:
Java
```private static void merge(Comparable[] a, Comparable[] aux,
int lo, int mid, int hi) {
for(int k = lo; k <= hi; k++) aux[k] = a[k];
int i = lo, j = mid + 1;
for(int k = lo; k <= hi; k++) {
if(i > mid)
else if(j > hi)
else if(less(aux[j], aux[i]))
else
}
}
public class Merge {
private static void merge(/*...*/) { /* as before */ }

private static void sort(Comparable[] a, Comparable[] aux,
int lo, int hi) {
if(hi <= lo) return;
int mid = lo + (hi - lo) / 2;
sort(a, aux, lo, mid);
sort(a, aux, mid+1, hi);
merge(a, aux, lo, mid, hi);
}

public static void sort(Comparable[] a) {
Comparable[] aux = new Comparable[a.length];
sort(a, aux, 0, a.length - 1);
}
}```

What I have tried:

I tried reviewing the code but I still can't figure out why it would'nt run. Please help
Posted
Updated 19-Jan-23 23:33pm
v2

## Solution 1

Mostly because it won't compile.
Java
```for(int k = lo; k <= hi; k++) {
if(i > mid)
else if(j > hi)
else if(less(aux[j], aux[i]))
else
}
```
None of your conditional code contains any executable lines after the condition: That won't compile at all.
You have this:
Java
```if (condition)
else if (other condition)
else```
And you need this:
Java
```if (condition)
something to do when it is true
else if (other condition)
something to do when it is true
else
something to do when neither was true```

v2
CPallini 19-Jan-23 2:18am
5.

## Solution 3

Given all these Java questions you have posted, I would advise you to go to Java Tutorials Learning Paths[^], and spend some time studying the language.