Math class is part of java.lang package. Math abs method returns the absolute value of any number. It means if value is in negative form, it will convert to positive form and return positive value.
Math abs example explains how to use Math abs function in java.
public class MathABSExample { public static void main(String[] args) { double E = Math.abs(-3.1456); //minus value System.out.println("Math abs value :"+E); } }
Output
Math abs value :3.1456



Link to Us