Javatpoint Logo
Javatpoint Logo

Java Absolute Value

Java abs() method

Java standard class library includes an absolute value method, called abs(). Java abs() method is overloaded by Math class to handle all the primitive types. Java determines which version of the abs() method to call. It depends on the type of argument.

In Java, we can find the absolute value by using the abs() method. It belongs to java.lang.Math class. It is an overloaded method. It returns the absolute value of an argument. The argument can be of any type such as int, float, double, long, and short. The signature of the method is:

Where x is an argument whose absolute value is to be determined.

Points to remember

  • If the argument is positive, the same argument is returned.
  • If the argument is negative, the same argument without the minus sign is returned.
  • If the argument is positive zero or negative zero, the result is always positive zero.
  • If the argument is not a number (NaN), the result is NaN.
  • If the argument is infinite, the result is Infinity.
  • If the passed argument is Integer.MIN_VALUE and Long.MIN_VALUE, the result is that same value.



Min value of integer is: -2147483648
Min value of long is: -922337203685477808

Next TopicJava Tutorial

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA