# Program: How to get absolute value in java?

 Description: In mathematics, the absolute value (or modulus) |a| of a real number a is the numerical value of a without regard to its sign. So, for example, the absolute value of 3 is 3, and the absolute value of -3 is also 3. The absolute value of a number may be thought of as its distance from zero. Below example shows how to get absolute value using Math.abs() method.

 Code: ```package com.java2novice.math; public class MyAbsEx { public static void main(String[] args) { double a = -23.45; int b = 234; double c = 12.54; System.out.println("absolute value of a: "+Math.abs(a)); System.out.println("absolute value of b: "+Math.abs(b)); System.out.println("absolute value of c: "+Math.abs(c)); } } ```

 Output: ```absolute value of a: 23.45 absolute value of b: 234 absolute value of c: 12.54 ```

#### List Of All Math Class Sample Programs:

Knowledge Centre
Pass by value Vs Pass by reference
Pass by value: Passing a copy of the value, not the original reference.

Pass by reference: Passsing the address of the object, so that you can access the original object.
Famous Quotations
Good judgment comes from experience, and experience comes from bad judgment.
-- Barry LePatner