absolute value java

Java
public class Test { 

   public static void main(String args[]) {
      Integer a = -8;
      double d = -100;
      float f = -90;

      System.out.println(Math.abs(a));
      System.out.println(Math.abs(d));     
      System.out.println(Math.abs(f));    
   }
}abs(intx);// Java program to demonstrate working 
// of java.lang.Math.abs() method 
import java.lang.Math; 
  
class Gfg { 
  
    // driver code 
    public static void main(String args[]) 
    { 
  
        float a = 123.0f; 
        float b = -34.2323f; 
  
        double c = -0.0; 
        double d = -999.3456; 
  
        int e = -123; 
        int f = -0; 
  
        long g = -12345678; 
        long h = 98765433; 
  
        // abs() method taking float type as input 
        System.out.println(Math.abs(a)); 
        System.out.println(Math.abs(b)); 
  
        // abs() method taking double type as input 
        System.out.println(Math.abs(1.0 / 0)); 
        System.out.println(Math.abs(c)); 
        System.out.println(Math.abs(d)); 
  
        // abs() method taking int type as input 
        System.out.println(Math.abs(e)); 
        System.out.println(Math.abs(f)); 
        System.out.println(Math.abs(Integer.MIN_VALUE)); 
  
        // abs() method taking long type as input 
        System.out.println(Math.abs(g)); 
        System.out.println(Math.abs(h)); 
        System.out.println(Math.abs(Long.MIN_VALUE)); 
    } 
} 

Source

Also in Java: