Java StrictMath.abs(float a)

Syntax

StrictMath.abs(float a) has the following syntax.

public static float abs(float a)

Example

In the following code shows how to use StrictMath.abs(float a) method.


public class Main {
/*from  ww w  . j a va  2 s  .  com*/
  public static void main(String[] args) {
  
    float f1 = 12, f2 = -1;
    
    System.out.println("absolute value of " + f1 + " = " + 
        StrictMath.abs(f1));
   
    System.out.println("absolute value of " + f2 + " = " + 
        StrictMath.abs(f2));
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable