Mergesort Implementation Help (Java)
===

Okay, I know this question doesn't show research effort, but I've been going through this code so many times and I couldn't figure out was I was doing wrong. I know there are many Mergesort implementation examples but I wanted to do it my way. Any help is appreciated, thanks.

    import java.util.Scanner;
    public class MergeSort
    {
    	public static int[] mergeSort(int[] arr)
    	{
    		if (arr.length > 1)
    		{
    			int[] arr1 = splitLeft(arr);
    			int[] arr2 = splitRight(arr);
    			arr1 = mergeSort(arr1);
    			arr2 = mergeSort(arr2);
    			return merge(arr1, arr2);
    		}
    		else
    			return arr;
    	}
    	
    	public static int[] splitLeft(int[] arr)
    	{
    		int middle = arr.length / 2;
    		int[] newarr = new int[middle];
    		for (int i = 0; i < middle; i++)
    			newarr[i] = arr[i];
    		return newarr;
    	}
    	
    	public static int[] splitRight(int[] arr)
    	{
    		int middle = arr.length / 2;
    		int[] newarr = new int[arr.length - middle];
    		for (int i = middle; i < arr.length; i++)
    			newarr[i] = arr[i];
    		return newarr;
    	}

	public static int[] merge(int[] arr1, int[] arr2)
	{

		int[] sorted = new int[arr1.length+arr2.length];
		
		int i1 = 0;
		int i2 = 0;
		int i = 0;
		
		while (i1 < arr1.length && i2 < arr2.length)
		{
			if (arr1[i1] < arr2[i2])
			{
				sorted[i] = arr1[i1];
				i1++;
			}
			
			else
			{
				sorted[i] = arr2[i2];
				i2++;
			}
		i++;
		}
		
		while (i1 < arr1.length) 
		{
			sorted[i] = arr1[i1];
			i1++;
			i++;
		}
		
		while (i2 < arr2.length) 
		{
			sorted[i] = arr1[i2];
			i2++;
			i++;
		}
		
		return sorted;
	}
    }