I a, getting the output as 10 9 9 10 for this program but I am not able to understand why swapping is not working.
Given below is the code:
public class Swap {
public static void main(String[] args) {
int a=9;
int b=10;
swap(a, b);
System.out.println(a);
System.out.println(b);
}
public static void swap(int a ,int b){
int temp=0;
temp=a;
a=b;
b=temp;
System.out.println(a);
System.out.println(b);
}