javaDay01_小练习
程序员文章站
2022-05-03 13:08:56
package zrs; public class Demo4 { public static void main(String[] args) { //练习题 //高效率的计算2*8 System.out.println("2*8="+(2<<3)); //交换两个变量的值 int a1=3; i ......
package zrs;
public class demo4 {
public static void main(string[] args) {
//练习题
//高效率的计算2*8
system.out.println("2*8="+(2<<3));
//交换两个变量的值
int a1=3;
int b1=5;
int temp=a1;
a1=b1;
b1=temp;
system.out.println("a1="+a1+",b1="+b1);
-------------------------------------------------------------------------------------
//这个是真的66666
int a=3;
int b=5;
//不添加新的变量
a=a+b;//a=3+5=8
b=a-b;//b=8-5=3
a=a-b;//a=8-3=5
system.out.println("a="+a+",b="+b);
}
}