class insertionSort
{
public void print(int arr[])
{
arr[0]=999999999;
}
}
public class Sorting
{
private int[] arr= {0,56,8,75,45,21,68,9,54,2,65,87,52,65,8,5,20,0,2,2};
public static void main(String[] arg)
{
Sorting sort = new Sorting();
insertionSort inSort = new insertionSort();
inSort.print(sort.arr);
System.out.println(sort.arr[0]);
}
}
Although Sort.arr is a private variable , why inSort object is able to manipulate arr[0] ?
I know the parameter is passing by reference or address.
In a function how can I pass by value ?