运算符

模运算:%

不等:!=,只有这种表示不等,不是<>,也不是≠

instanceof

byte+short=int:byte(short)类型再相加的时候,会自动转换成int类型

public class Annotation {
public static void main(String[] args) {
long a = 100;
int b = 10;
short c = 5;
byte d = 1;
System.out.println((String)(a+b));
System.out.println((String)(c+d));
}
}

关系运算符返回结果:布尔值

一元运算符:

public class Annotation {
   public static void main(String[] args) {
       int a = 10;
       int b = a++;//先赋值,再自增
       int c = ++a;//先自增,再赋值
       System.out.println(b);
       System.out.println(c);
  }
}

运算结果:

10
10

Math类:很多运算都会用一些工具类来实现

  1. abs():绝对值

  2. pow():幂运算