1public class Test {
2
3 public static void main(String args[]) {
4 Integer a = -8;
5 double d = -100;
6 float f = -90;
7
8 System.out.println(Math.abs(a));
9 System.out.println(Math.abs(d));
10 System.out.println(Math.abs(f));
11 }
12}
1float a = 123.0f;
2System.out.println(Math.abs(a)); //123.0
3
4double d = -999.3456;
5System.out.println(Math.abs(d)); //999.3456
6
7int e = -123;
8System.out.println(Math.abs(g)); //123
9
10long g = -12345678;
11System.out.println(Math.abs(g)); //12345678