In: Computer Science
public class SwaptTest {
public static void main(String[] args) {
swap(10, 20);
}
private static void swap(int a, int b) {
System.out.println("Before swap a =
"+a+" b = "+b);
//storing a value in c
int c=a;
//assigning b value to a
a=b;
//assigning c value to a(old a
value)
b=c;
System.out.println("After swap a =
"+a+" b = "+b);
}
}
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me