Java Data Type Tutorial - Java Math.cosh(double x)








Syntax

Math.cosh(double x) has the following syntax.

public static double cosh(double x)

Example

In the following code shows how to use Math.cosh(double x) method.

//from w w  w  .  j  av  a  2 s.  co  m
public class Main {

   public static void main(String[] args) {

      double x = 45.0;
      double y = 180.0;

      // convert them to radians
      x = Math.toRadians(x);
      y = Math.toRadians(y);

      // output their hyperbolic cosine
      System.out.println("Math.cosh(" + x + ")=" + Math.cosh(x));
      System.out.println("Math.cosh(" + y + ")=" + Math.cosh(y));


   }
}

The code above generates the following result.