Our teacher gave us the pseudocode for Merge Sort as below

I want to implement it in Java. My code is below:
public class MergeSorter {
/**
* @param anArray
*/
public MergeSorter(int[] anArray,int low, int high)
{
a = anArray;
p = low;
r = high;
}
public void sort()
{
if(p < r)
{
q = (p + r)/2;
MergeSorter pqSorter = new MergeSorter(a, p, q);
MergeSorter qrSorter = new MergeSorter(a, q + 1, r);
pqSorter.sort();
qrSorter.sort();
merge(p, q, r);
}
}
private void merge(int low, int mid, int high)
{
p = low;
q = mid;
r = high;
int i;
int j;
int n1 = (q - p) + 1;
int n2 = (r - q);
int[] L = new int[n1+1];
for (i = 0; i < n1; i++)
{
L[i] = a[(p + i)];
}
int[] R = new int[n2+1];
for (j = 0; j < n2; j++)
{
R[j] = a[q + j];
}
L[n1] = Integer.MAX_VALUE;
R[n2] = Integer.MAX_VALUE;
i = 0;
j = 0;
for (int k = p; k < r; k++)
{
count = count + 1;
if(L[i] <= R[j])
{
a[k] = L[i];
i = i + 1;
}
else
{
a[k] = R[j];
j = j + 1;
}
}
}
private int[] a;
private int p;
private int r;
private int q;
public int count = 0;
}
But this code is not working.I want to know where is the problem. Sorry for the wrong direction picture. Updated: Here is my other code.It now dose something but not sorted right. This is my test code below
public static void main(String[] args) throws FileNotFoundException, IOException
{
int[] a = {1,4,6,2,10,7};
MergeSorter sorter = new MergeSorter(a,0,a.length);
sorter.sort();
System.out.println(Arrays.toString(a));
}
It output [1,2,4,4,2,7] as a result.