package com.lirun.operator;
public class Demo04 {
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);
//幂运算 2^3 2*2*2* = 8,很多运算,会用一些工具类来操作
double pow = Math.pow(3,2);//Math.pow幂运算
System.out.println(pow);
}
}
本文提供了一个简单的Java程序示例,演示了如何使用自增自减运算符以及如何进行幂运算。通过具体的代码展示了变量的自增自减操作,并使用Math类中的pow方法进行了幂运算。
638

被折叠的 条评论
为什么被折叠?



