Math.abs(float a) has the following syntax.
public static float abs(float a)
In the following code shows how to use Math.abs(float a) method.
/* ww w. j a va2 s. c o m*/ public class Main { public static void main(String[] args) { float x = 1.2345f; float y = -123.45f; System.out.println(Math.abs(x)); System.out.println(Math.abs(y)); System.out.println(Math.abs(-123.0f)); } }
The code above generates the following result.