Search⌘ K

Using the Math Class

Explore the Java Math class and understand how to use its static methods for advanced mathematical computations. This lesson helps you grasp calling static methods, including those within the same or different classes, and shows how Math class methods extend beyond basic operators for tasks like finding max, min, rounding, logarithms, square roots, and trigonometric calculations.

Introducing the Math class

As discussed in the previous unit, classes are grouped in a package. Java provides a built-in class, known as the Math class. It is a part of the java.lang package. Thus, the fully qualified class name is java.lang.Math. This class only contains static ...