Home » Core Java » math » Page 2

math

Find the maximum of numbers with Math.max in Java

In this example, we shall show you how to find the maximum numbers in Java, using the Math Class and the method Math.max. 1. About Math Class The java.lang.Math class contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. By using the associated functions directly, you can skip creating the logic ...

Read More »

Generate random numbers with Math random

With this example we are going to demonstrate how to generate random numbers using random() method of Math Class. The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. In short, to generate random numbers you should: Call random() API method of Math. This method returns a double value ...

Read More »

Calculate square root in Java with Math sqrt

This is an example of how to calculate the square root in Java, using the sqrt(double a) method of Math Class. The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. Calculating the square root of a number implies that you should: Use the sqrt(double a) method of Math Class. The method gets a double ...

Read More »

Calculate power with Math pow

In this example we shall show you how to calculate the power of a number using the pow(double a, double b)  API method of Math Class. The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. To calculate the power of a number one should perform the following steps: ...

Read More »