代码
提交代码
public class ArithmeticExpression2 { public static void main(String[] args) { // 前自增 System.out.println("------ 前自增 ------"); int num = 10; System.out.println("++num = " + (++num)); System.out.println("num = " + num); // 前自减 System.out.println("------ 前自减 ------"); num = 10; System.out.println("--num = " + (--num)); System.out.println("num = " + num); // 后自增 System.out.println("------ 后自增 ------"); num = 10; System.out.println("num++ = " + (num ++)); System.out.println("num = " + num); // 前自减 System.out.println("------ 前自减 ------"); num = 10; System.out.println("num-- = " + (num --)); System.out.println("num = " + num); } }
运行结果