Java Mathabs() Method
Example
Return the absolute (positive) value of different numbers:
System.out.println(Math.abs(-4.7));System.out.println(Math.abs(4.7));System.out.println(Math.abs(3));Definition and Usage
Theabs() method returns the absolute (positive) value of a number.
Syntax
One of the following:
public static double abs(doublenumber)public static float abs(floatnumber)public static int abs(intnumber)public static long abs(longnumber)Parameter Values
| Parameter | Description |
|---|---|
| number | Required. Specifies a number |
Technical Details
| Returns: | Adouble,float,int orlong value representing the absolute value of the specified number |
|---|
❮ Math Methods

