Get the absolute value

ReturnMethodSummary
static doubleabs(double a)Returns the absolute value of a double value.
static floatabs(float a)Returns the absolute value of a float value.
static intabs(int a)Returns the absolute value of an int value.
static longabs(long a)Returns the absolute value of a long value.

public class Main {
  public static void main(String[] args) {

    System.out.print(Math.abs(-1.23));
  }
}

The output:


1.23
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.