TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Java

Java Math Class

Overview

In this tutorial, we will learn about Java Math class. The Math class provides commonly used mathematical functions like square root, exponential(exp), logarithm(log), and trigonometric functions like sin, cosine, tan etc. The class provides several static methods for the mathematical functions.

Java Math Class

Java Math class is a final class with private constructor. So we cannot further extend the class or create objects for the class. The class contains constants for the values of E(base of natural logarithm), PI (ratio of the circumference of a circle to its diameter) and conversation factors to change degrees to radians and vice versa.

Examples

Let’s look at an example to calculate square root of a number using the Math class method.

Math.sqrt(number)

For example, to compute the square root of 10

Math.sqrt(10)

To compute square root of number 9

Math.sqrt(9)

 

public class MathClassDemo {
 public static void main(String[] args) {
 //Compute square root of 9
 System.out.println(Math.sqrt(9));
 }
}

Java Math Class

—

Java Tutorials

Java Tutorial on this website:

https://www.testingdocs.com/java-tutorial/

For more information on Java, visit the official website :

https://www.oracle.com/in/java/

Related Posts

Download Greenfoot Windows

Java /

Download & Install Greenfoot on Windows

Java /

Java Static Code Analysis

Java /

Java Testing Tools

Java /

Handle Multiple Exceptions in Java

Exceptions_In_Java

Java /

Exceptions in Java Programs

‹ java.util Package› Autoboxing and Unboxing in Java

Recent Posts

  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Print Triangle Pattern Flowchart
  • RAPTOR Editions
  • Flowgorithm Conditional Breakpoint Statement
  • Flowgorithm Read Numbers from File Example
  • Search Text File Flowchart Example
  • Flowgorithm Turtle Graphics Symbols
  • Draw Circle using Flowgorithm Turtle

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version