public class Test {
public static void main(String[] args){
int a=1;//定义一个变量a,赋初值为1
int b=2;//定义一个变量b,赋初值为2
System.out.println(a);//打印a
System.out.println(b);//打印b
//a与b互换
a=a+b;
b=a-b;
a=a-b;
System.out.println("===========================");
System.out.println(a);//互换后打印a
System.out.println(b);//互换后打印b
//a与b互换
a=a^b;
b=a^b;
a=a^b;
System.out.println("===========================");
System.out.println(a);//互换后打印a
System.out.println(b);//互换后打印b
} |
|