public class Test{
public static void main(String[] args) {
swap(5,6);
}
public static void swap(int a,int b) {
System.out.println(a+" "+b);
a+=b;
b=a-b;
a=a-b;
System.out.println(a+" "+b);
}
}
结果
5 6
6 5
public class Test{
public static void main(String[] args) {
swap(5,6);
}
public static void swap(int a,int b) {
System.out.println(a+" "+b);
a+=b;
b=a-b;
a=a-b;
System.out.println(a+" "+b);
}
}
结果
5 6
6 5