a++

public class Demon12 {
public static void main(String[] args) {
int a = 3;
int b = a++;
System.out.println(a);
int c =++a;
System.out.println(a);
System.out.println(b);
System.out.println(c);
}
}
输出:

4
5
3
5

Process finished with exit code 0

public class Demon12 {
public static void main(String[] args) {
//++ -- 自增 自减 属于一元运算符
int a = 3;
int b = a++;//先赋值b=3,再增加1.
//a=a+1
System.out.println(a);
//a=a+1
int c =++a;//执行该代码前先加1,再给c赋值。
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println("===============");

//用以求3的2次方。
double pow = Math.pow(3,2);
System.out.println(pow);
}
}
输出:

4
5
3
5
===============
9.0

Process finished with exit code 0

posted @ 2021-08-19 14:03  小风扇呜呜呜  阅读(374)  评论(0)    收藏  举报