bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Math abs() Method

❮ Math Methods

Example

System.out.println(Math.abs(-4.7));
System.out.println(Math.abs(4.7));
System.out.println(Math.abs(3));

Definition and Usage

The abs() method returns the absolute (positive) value of a number.

One of the following

public static double abs(double
number )
public static float abs(float
number )
public static int abs(int
number )
public static long abs(long
number )

Parameter Values

ParameterDescription
numberRequired. Specifies a number

Technical Details

Returns:A double , float , int or long value representing the absolute value of the specified number

Previous

Java Math Methods

Next

Java Math acos() Method