The technique gives the whole value of the argument. The argument can be int, float, long, double, short, byte.
Following are all the variants of this method:
double abs(double d) float abs(float f) int abs(int i) long abs(long lng)
Here is the detail of parameters −
Example
public class Test { public static void main(String args[]) { Integer a = -8; double d = -100; float f = -90; System.out.println(Math.abs(a)); System.out.println(Math.abs(d)); System.out.println(Math.abs(f)); } }
This will produce the following result −
8 100.0 90.0
Here at Intellinuts, we have created a complete Java tutorial for Beginners to get started in Java.