java.lang.StrictMath atan​(double a)

Description

The atan​(double a) method of StrictMath class returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2.

Special cases:

  • If the argument is NaN, then the result is NaN.
  • If the argument is zero, then the result is a zero with the same sign as the argument.

Notes:

The atan​(double a) method of StrictMath class is static thus it should be accessed statically which means the we would be calling this method in this format:

StrictMath.atan​(double a)

Non static method is usually called by just declaring method_name(argument) however in this case since the method is static, it should be called by appending the class name as suffix. We will be encountering a compilation problem if we call the java compare method non statically.

Method Syntax

public static double atan​(double a)

Method Argument

Data Type Parameter Description
double a the value whose arc tanget is to be returned.

Method Returns

The atan​(double a) method returns the arc tangent of the argument.

Compatibility

Requires Java 1.3 and up

Java StrictMath double atan​(double a) Example

Below is a java code demonstrates the use of atan​(double a) method of StrictMath class. Basically the program below ask for two user input, one for opposite and the other is adjacent sides. Our example program is design to calculate an angle given the user input.

Take note of the usage of toDegrees() which we have used . The method acos() returns an angle in radians which is not usually used thus we have used the toDegrees method to convert the result to degrees.

Sample Output

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

Java Strictmath atan method example