java.lang.Math.sinh()
Description
- If the argument is NaN, then the result is NaN.
- If the argument is infinite, then the result is an infinity with the same sign as the argument.
- If the argument is zero, then the result is a zero with the same sign as the argument.
Most of the methods of the Math class is static and the sinh() method is no exception. Thus don’t forget that in order to call this method, you don’t have to create a new object instead call it using Math.sinh(x).
Method Syntax
public static double sinh(double x)
Method Argument
Data Type | Parameter | Description |
---|---|---|
double | x | The number whose hyperbolic sine is to be returned. |
Method Returns
The Math.sinh() method returns the hyperbolic sine of the argument x.
Compatibility
Requires Java 1.5 and up
Java Math sinh() Example
Below is a java code demonstrates the use of sinh() method of Math class. The example presented might be simple however it shows the behaviour of the sinh() method.
package com.javatutorialhq.java.examples; import java.util.Scanner; /* * This example source code demonstrates the use of * sinh() method of Math class */ public class MathSinhExample { public static void main(String[] args) { // Ask for user input System.out.print("Enter a value:"); // use scanner to read the console input Scanner scan = new Scanner(System.in); // Assign the user to String variable String s = scan.nextLine(); // close the scanner object scan.close(); // convert the string input to double double value = Double.parseDouble(s); // get the hyperbolic sine of the user input double sineValue = Math.sinh(value); System.out.println("Hyperbolic Sine of " + s + " is " + sineValue); } }
The above java example source code demonstrates the use of sinh() 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 sinh() method accepts double method argument.