Math.abs(int a) has the following syntax.
public static int abs(int a)
In the following code shows how to use Math.abs(int a) method.
// w w w . ja va 2 s.c o m public class Main { public static void main(String[] args) { int x = 123; int y = -123; System.out.println(Math.abs(x)); System.out.println(Math.abs(y)); System.out.println(Math.abs(-0)); } }
The code above generates the following result.