I am new to programming and I was trying to implement Quicksort on java.My code seems is working perfectly. But there is something I can't understand The static method called 'partition'(as you can see below in the code snippet) returns an 'int'type variable and manipulates the array 'arr'. Now when I call QuickSortAlgo method with input as 'arr', why is this 'arr' array that goes inside the QuickSortAlgo method the manipulated/modified array (modified in the method 'partition')? When the method 'partition' ends shouldnt the array 'arr'(which was modified in partition) be forgotten since the method 'partition' only returns an 'int'?
public static double[] QuickSortAlgo(double arr[],int low, int high){
if(low<high){
int pi=partition(arr,low,high);
QuickSortAlgo(arr, low, pi-1); // Before pi
QuickSortAlgo(arr, pi+1, high); // After pi
}