i saw this Heap Sort program on geeksForGeeks: https://www.geeksforgeeks.org/heap-sort/
in main method(), they've taken an int[] and passed it to sort(). After that they passed the same int[] to a utility function printArray() for printing and it prints the sorted array . I tried the same to swap 2 variables, but it doesnt work .
public void swap(int a,int b){
int t=a;
a=b;
b=t;
}
public static void printVal(int a,int b){
System.out.println("New value \n a: "+a+", b: "+b);
}
public static void main(String[] args) {
ArrayEx ae= new ArrayEx();
int a=5;
int b=10;
System.out.println("Old value \n a: "+a+", b: "+b);
ae.swap(a, b);
printVal(a,b);
}
can anyone please tell how argument passing and processing works in java ?
Thanks in advance