I have a function that sorts a given array using the merge sort algorithm. That algorithm calls itself to solve the problem.
public class MergeSort {
    
    public static void mergeSort(int[][] arr, int left, int right) {
        // merge two parts
        merge(arr, left, mid, right);
        
        // sort the left part
        mergeSort(arr, left, mid);
        // sort the right part
        mergeSort(arr, mid, right);
    }   
}
Can I reach performance if I encapsulate the arr parameter in the class? Consider:
public class MergeSort {
    int[][] arr;
    
    public void mergeSort(int left, int right) {
        // merge two parts
        merge(left, mid, right);
        
        // sort the left part
        mergeSort(left, mid);
        // sort the right part
        mergeSort(mid, right);
    }
}
So, the arr parameter is not passing to the stack.
 
     
    