1.中间变量(在开发中常用)
int c=a;
a=b;
b=c;
System.out.println("a的值: "+a+" b的值: "+b);
2.按位异或(面试,只能是整数)
a=a^b;
b=a^b;//a^b^b=a
a=a^b;//a^b^a=b
System.out.println("a的值: "+a+" b的值: "+b);
3.相加(面试)
a=a+b;
b=a-b;//a+b-b=a
a=a-b;//a+b-a=b
System.out.println("a的值: "+a+" b的值: "+b);