In java, The Math.abs() function returns the absolute value of a specified number.
refer totual:turi.com/**
* @author lautturi.com
* Java example: get the absolute value of a specified number
*/
import java.util.*;
public class Lautturi {
public static void main(String[] args) {
Integer i = -6;
double d = -3.14;
float f = 1.414f;
System.out.println(Math.abs(i));
System.out.println(Math.abs(d));
System.out.println(Math.abs(f));
}
}
output:
6 3.14 1.414