abs() 返回参数的绝对值。参数可以是 int, float, long, double, short, byte类型。
System.out.println(Math.abs((int)-100));
System.out.println(Math.abs((float)-90));
System.out.println(Math.abs((long)-80));
System.out.println(Math.abs((double)-70));
System.out.println(Math.abs((short)-60));
System.out.println(Math.abs((byte)-50));
输出结果为:
100
90.0
80
70.0
60
50