自增運算符:
以 a++ 和 ++a 為例
public class Demo4 {
public static void main(String[] args) {
//++ -- 自增自減 一元運算符
int a = 3;
int b = a++;//先將a的值賦給 b,再給 a 自增
System.out.println(a);//此時a的值變?yōu)?4
int c = ++a;//先給 a 自增,再將值賦給 c
System.out.println(a);//此時 a 的值變?yōu)?5
System.out.println(b);
System.out.println(c);
//冪運算
double pow = Math.pow(2, 3);
System.out.println(pow);
}
}
|