Description

On this document we will be showing a java example on how to use the asin(double a) method of Math Class. The asin(double a) returns the arc sine of the method argument value. The returned angle is in the range -pi/2 through pi/2. The following rule must be noted

  • If the argument is NaN or its absolute value is greater than 1, then the result is NaN.
  • If the argument is zero, then the result is a zero with the same sign as the argument.

The arc sine of value is basically just the inverse sine of a value. To further illustrate this below is the equation.

asin(a) = sin-1a

Most of the methods of the Math class is static and the asin() method is no exception. Thus don’t forget that in order to call this method, you don’t have to create a new object. Use the method in the format Math.asin(a).

Method Syntax

public static double asin(double a)

Method Returns

The asin() method returns the arc sine of the argument.

Compatibility

Requires Java 1.0 and up

Java Math asin() Example

Below is a java code demonstrates the use of asin() method of Math class. The example presented might be simple however it shows the behavior of the asin() method.

The above java example source code demonstrates the use of asin() method of Math class. We simply ask for user input and we use the Scanner class to parse it. Since we have used the nextLine() method to get the console value, and the return data type is String thus we have used the Double.parseDouble() to transform it into double. We have to convert it first to double because the asin() method accepts double method argument.

Sample Output

Below is the sample output when you run the above example.

java lang Math asin() example output