Using the Math Class
Understand the basics of Math class.
We'll cover the following
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 methods.
Calling a static method
Remember that the static methods are called using the .
operator, along with the class name unless they are defined in the enclosing class.
Consider the executable below.
Get hands-on with 1400+ tech skills courses.