Java Math cosh() Method Last Updated : 12 May, 2025 Comments Improve Suggest changes Like Article Like Report In Java, the cosh() method is a part of the java.lang.Math class. This method is used to calculate the hyperbolic cosine of a given double value.Mathematical Definition:The hyperbolic cosine of any value a is defined as:(ea + e-a)/2where, e is Euler's number. Special Cases: The cosh() method handles different cases, which are listed below,If the argument is NaN, then the result is NaN.If the argument is infinity then the result will be positive infinity.If the argument is zero, then the result is one. These special cases make sure that the Math.cosh() methods work correctly.Syntax of cosh() Methodpublic static double cosh(double a)Parameter: This method takes a single parameter a, which is the value whose hyperbolic cosine is to be returned.Return Type: This method returns the hyperbolic cosine value of the argument. Now, we are going to discuss some exampls for better understanding.Examples of Java Math cosh() MethodExample 1: In this example, we will see the basic usage of cosh() method. Java // Java program to demonstrate working // of Math.cosh() method import java.lang.Math; class Geeks { public static void main(String args[]) { double a = 3.5; // Displaying hyperbolic cosine of 3.5 System.out.println(Math.cosh(a)); a = 90.328; // Displaying hyperbolic cosine of 90.328 System.out.println(Math.cosh(a)); } } Output16.572824671057315 8.470751974588509E38 Explanation: Here, we are calculating the hyperbolic cosine of given numbers. First, we are calculating the hyperbolic cosine of 3.5 and after that we are calculating the cosine of 90.328.Example 2: In this example, we will see how cosh() method handles NaN and Infinity. Java // Java program to demonstrate working // Math.cosh() method with NaN and Infinity import java.lang.Math; public class Geeks { public static void main(String[] args) { double p = Double.POSITIVE_INFINITY; double n = Double.NEGATIVE_INFINITY; double nan = Double.NaN; double res; // here argument is negative infinity res = Math.cosh(n); System.out.println(res); // here argument is positive infinity res = Math.cosh(p); System.out.println(res); // here argument is NaN res = Math.cosh(nan); System.out.println(res); } } OutputInfinity Infinity NaN Comment More infoAdvertise with us Next Article StrictMath cosh() Method in Java B barykrg Follow Improve Article Tags : Java Technical Scripter Java-Library Java-lang package java-math +1 More Practice Tags : Java Similar Reads Java Math cosh() method with Examples In Java, the cosh() method is a part of the java.lang.Math class. This method is used to calculate the hyperbolic cosine of a given double value.Mathematical Definition:The hyperbolic cosine of any value a is defined as:(ea + e-a)/2where, e is Euler's number. Special Cases: The cosh() method handles 2 min read StrictMath cosh() Method in Java The java.lang.StrictMath.cosh() is an inbuilt method in Java which returns the hyperbolic cosine value of a given double argument. The method returns NaN when the argument is NaN. The method returns a positive infinity when the argument is infinity. The method returns 1.0 when the given argument is 2 min read Java Math Class Java.lang.Math Class methods help to perform numeric operations like square, square root, cube, cube root, exponential and trigonometric operations.Declarationpublic final class Math extends Object Methods of Math Class in JavaMath class consists of methods that can perform mathematical operations a 7 min read Java Math tanh() method with Examples In Java, the tanh() method is a part of the java.lang.Math class. This method returns the hyperbolic tangent of a double value passed to it as an argument. Mathematical Definition:The hyperbolic tangent of any value a is defined as:((ea - e-a)/2)/((ea + e-a)/2)where, e is Euler's number, whose value 2 min read Java Math sinh() method with Examples In Java, the sinh() method is a part of the java.util.Math class. This method is used to calculate the hyperbolic sine of a given value. In this article, we are going to discuss how this method works for regular values and for special cases such as infinity and NaN.Mathematical Definition:The hyperb 3 min read Set hashCode() Method in Java In Java, the hashCode() method is defined in the Object class and is used to generate a hash code for objects. It plays a very important role in hash-based collections like HashMap, HashSet, and HashTable. Example 1: This example demonstrates how hashCode() is used to get the hash code of the HashSe 2 min read LinkedHashMap clear() Method in Java The clear() method in Java is a built-in method of the java.util.LinkedHashMap class. This method is used to remove all the key-value mappings from a LinkedHashMap. After invoking this method, the map becomes empty.This method is very helpful when we want to reuse an existing map object without crea 2 min read Java AbstractMap hashCode() Method The hashCode() method of the AbstractMap class in Java is used to calculate a hash code value for a map. This hash code is based on the key-value mapping contained in the map. It ensures consistency such that two maps with the same entries have the same hash code.Example 1: Hash Code of a Non-Empty 2 min read YearMonth hashCode() method in Java The hashCode() method of YearMonth class in Java is used to create a suitable hash code for this YearMonth instance with which it is used. Syntax: public int hashCode() Parameter: This method does not accepts any parameter. Return Value: It returns a suitable integral hash code value for this YearMo 1 min read Method Class | toGenericString() method in Java The java.lang.reflect.Method.toGenericString() method of Method class returns a string which gives the details of Method, including details of type parameters of the method. Syntax: public String toGenericString() Return Value: This method returns a string which gives the details of Method, includin 3 min read Like