What is the use of StrictMath class in Java?

JavaObject Oriented ProgrammingProgramming

<p>The <strong>java.lang.StrictMath&nbsp;</strong>is a final class and it is a subclass of <strong>Object&nbsp;</strong>class. The StrictMath class contains methods for performing basic numeric operations such as the elementary <strong>exponential, logarithm, square root</strong>, and <strong>trigonometric functions</strong>. We need not create an instance for <strong>StrictMath&nbsp;</strong>class because all the methods in StrictMath class are <strong>static methods</strong>. The important methods of StrictMath class are <strong>abs(), acos(), asin(), atan(), ceil(), floor(), log(), max(), min(), pow(), random(), round()</strong> and etc.</p><h2>Syntax</h2><pre class="prettyprint notranslate">public final class StrictMath extends Object</pre><h2>Example</h2><pre class="prettyprint notranslate">public class StrictMathTest { public static void main(String args[]) { System.out.println(&quot;Absolute Value: &quot; + StrictMath.abs(-100.50)); System.out.println(&quot;Ceil Value : &quot; + StrictMath.ceil(100.55)); System.out.println(&quot;Floor Value : &quot; + StrictMath.floor(100.55)); System.out.println(&quot;Maximum Value : &quot; + StrictMath.max(100,200)); System.out.println(&quot;Minimum Value : &quot; + StrictMath.min(100,200)); System.out.println(&quot;Random Value : &quot; + StrictMath.random()); System.out.println(&quot;Round Value: &quot; + StrictMath.round(100.75)); System.out.println(&quot;Square Root Value : &quot; + StrictMath.sqrt(2)); System.out.println(&quot;PI Value: &quot; + StrictMath.PI); System.out.println(&quot;Log Value: &quot; + StrictMath.log(10.55)); } }</pre><h2>Output</h2><pre class="result notranslate">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</pre>
Updated on 31-Jul-2019 11:09:37