Home > Java > javaTutorial > body text

What is the purpose of StrictMath class in Java?

PHPz
Release: 2023-09-12 21:21:02
forward
1374 people have browsed it

What is the purpose of StrictMath class in Java?

java.lang.StrictMath is a final class that is a subclass of the Object class. The StrictMath class contains methods for performing basic numerical operations, such as elementary exponents, logarithms, square roots, and trigonometric functions. We don't need to create an instance for the StrictMath class because all methods in the StrictMath class are static methods. The important methods of the StrictMath class are abs(), acos(), asin(), atan(), ceil(), floor(), log(), max(), min(), pow(), random(), round() etcSyntax

public final class StrictMath extends Object
Copy after login
Example

public class StrictMathTest {
   public static void main(String args[]) {
      System.out.println("Absolute Value: " + StrictMath.abs(-100.50));
      System.out.println("Ceil Value : " + StrictMath.ceil(100.55));
      System.out.println("Floor Value : " + StrictMath.floor(100.55));
      System.out.println("Maximum Value : " + StrictMath.max(100,200));
      System.out.println("Minimum Value : " + StrictMath.min(100,200));
      System.out.println("Random Value : " + StrictMath.random());
      System.out.println("Round Value: " + StrictMath.round(100.75));
      System.out.println("Square Root Value : " + StrictMath.sqrt(2));
      System.out.println("PI Value: " + StrictMath.PI);
      System.out.println("Log Value: " + StrictMath.log(10.55));
   }
}
Copy after login

Output

Absolute Value: 100.5
Ceil Value : 101.0
Floor Value : 100.0
Maximum Value : 200
Minimum Value : 100
Random Value : 0.22227639516105102
Round Value: 101
Square Root Value : 1.4142135623730951
PI Value: 3.141592653589793
Log Value: 2.3561258599220753
Copy after login

The above is the detailed content of What is the purpose of StrictMath class in Java?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template