注意+±-的先后顺序
package operator;
/**
* @author WZT
* @create 2021-03-24 9:37
*/
public class Demo04 {
public static void main(String[] args) {
//++ -- 自增自减,一元运算符
int a = 3;
int b = a++;//执行完这段代码后,先给b赋值,再自增
int c = ++a;//执行完这段代码后,先自增,再给c赋值,
System.out.println(a);
System.out.println(b);
System.out.println(c);
}
}
输出
5
3
5
Math类
//幂运算 2^3,使用工具类完成
double pow = Math.pow(3,2);![在这里插入图片描述](https://img-blog.csdnimg.cn/20210324094514304.bmp?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NTgwOTgzOA==,size_16,color_FFFFFF,t_70#pic_center)