public class freedom {
public static void main(String args[]){
int x = 10;
int y = 20;
System.out.println(" x is: "+x+" y is: "+y);
swap(x,y);
System.out.println(" x is: "+x+" y is: "+y);
}
public static void swap(int x, int y){
int temp = x;
x = y;
y = temp;
}
}
So i wrote a simple function to swap two values but for some reason they do not get swapped. I know the logic of my code is correct but I am wondering why the values are not swapped.