Found 9326 Articles for Object Oriented Programming

Get the hyperbolic tangent of a given value in Java

Arjun Thakur
Updated on 26-Jun-2020 09:54:43

151 Views

In order to get the hyperbolic tangent of a given value in Java, we use the java.lang.Math.tanh() method. The tanh() method accepts an argument in radians and returns the hyperbolic tan of the argument which acts as the angle.Declaration −The java.lang.Math.tanh() is declared as follows −public static double tanh(double x)where, x is the angle in radians.Let us see a program to get the hyperbolic tangent of a given value in Java.Example Live Demoimport java.lang.Math; public class Example {    public static void main(String[] args) {       // get two double numbers in degrees       double x = ... Read More

Check if the String contains only unicode letters in Java

Chandu yadav
Updated on 26-Jun-2020 09:55:48

11K+ Views

In order to check if a String has only Unicode letters in Java, we use the isDigit() and charAt() methods with decision-making statements.The isLetter(int codePoint) method determines whether the specific character (Unicode codePoint) is a letter. It returns a boolean value, either true or false.Declaration −The java.lang.Character.isLetter() method is declared as follows −public static boolean isLetter(int codePoint)Here, the parameter codePoint represents the character to be checked.The charAt() method returns a character value at a given index. It belongs to the String class in Java. The index must be between 0 to length()-1.Declaration −The java.lang.String.charAt() method is declared as follows −public ... Read More

Check if the String contains only unicode letters or digits in Java

George John
Updated on 26-Jun-2020 09:56:58

6K+ Views

To check whether a String contains only unicode letters or digits in Java, we use the isLetterOrDigit() method and charAt() method with decision-making statements.The isLetterOrDigit(char ch) method determines whether the specific character (Unicode ch) is either a letter or a digit. It returns a boolean value, either true or false.Declaration −The java.lang.Character.isLetter() method is declared as follows −public static boolean isLetter(char ch)The charAt() method returns a character value at a given index. It belongs to the String class in Java. The index must be between 0 to length()-1.Declaration −The java.lang.String.charAt() method is declared as follows −public char charAt(int index)Let us ... Read More

Get the base 10 logarithm of a value in Java

Ankith Reddy
Updated on 26-Jun-2020 09:57:36

939 Views

To get the base 10 logarithm of value in Java, we use the java.lang.Math.log10() method. This method returns the log of value to the base 10 in the form of a double. If a number is 10n, then the result is n. If the value passed is NaN or negative, the result is NaN. If the value passed is positive infinity, then the value returned is positive infinity. When the parameter is positive zero or negative zero, then negative infinity is returned.Declaration −The java.lang.Math.log10() method is declared as follows −public static double log10(double a)where a is a value whose base ... Read More

Get the hyperbolic sine of a given value in Java

Arjun Thakur
Updated on 26-Jun-2020 09:58:43

163 Views

In order to get the hyperbolic sine of a given value in Java, we use the java.lang.Math.sinh() method. The sinh() method accepts an argument in radians and returns the hyperbolic sine of the argument which acts as the angle.Declaration −  The java.lang.Math.sinh() is declared as follows −public static double sinh(double x)where x is the angle in radians.Let us see a program to get the hyperbolic sine of a given value in Java.Example Live Demoimport java.lang.Math; public class Example {    public static void main(String[] args) {       // get two double numbers in degrees       double x ... Read More

Get the hyperbolic cosine of a given value in Java

Chandu yadav
Updated on 26-Jun-2020 09:59:19

137 Views

In order to get the hyperbolic cosine of a given value in Java, we use the java.lang.Math.cosh() method. The cosh() method accepts an argument in radians and returns the hyperbolic cosine of the argument which acts as the angle.Declaration − - The java.lang.Math.cosh() is declared as follows −public static double cosh(double x)where x is the angle in radians.Let us see a program to get the hyperbolic cosine of a given value in Java.Example Live Demoimport java.lang.Math; public class Example {    public static void main(String[] args) {       // get two double numbers in degrees       double ... Read More

Round float and double numbers in Java

George John
Updated on 26-Jun-2020 10:00:20

8K+ Views

In order to round float and double numbers in Java, we use the java.lang.Math.round() method. The method accepts either double or float values and returns an integer value. It returns the closest integer to number. This is computed by adding ½ to the number and then flooring it.Declaration - The java.lang.Math.round() method is declared as follows −public static int round(float a) public static int round(double a)where a is the value to be rounded.Let us see a program where float and double numbers are rounded in Java.Example Live Demoimport java.lang.Math; public class Example {    public static void main(String[] args) {   ... Read More

Get square root of a number using Math.sqrt in Java

Ankith Reddy
Updated on 26-Jun-2020 10:00:56

1K+ Views

In order to get the square root of a number in Java, we use the java.lang.Math.pow() method. The Math.pow(double a) method accepts one argument of the double data type and returns a value which is the square root of the argument.Declaration − The java.lang.Math.sqrt() method is declared as follows −public static double sqrt(double a)where a is the number whose square root is to be found.Let us see a program where we find the square root of number using the Math.sqrt() method.Example Live Demoimport java.lang.Math; public class Example {    public static void main(String[] args) {       // declaring and ... Read More

Get power using Math.pow in Java

Arjun Thakur
Updated on 26-Jun-2020 10:01:34

376 Views

In order to get the power of a number in Java, we use the java.lang.Math.pow() method. The Math.pow(double a, double b) method accepts two arguments of the double data type and returns a value of the first parameter raised to the power of the second argument.Declaration - The java.lang.Math.pow() method is declared as follows −public static double pow(double a, double b)where a is the base and b is the power to which the base is raised.Let us see a program where we find the power of a number using Math.pow() methodExample Live Demoimport java.lang.Math; public class Example {    public static ... Read More

Get natural logarithm value using Math.log in Java

Chandu yadav
Updated on 26-Jun-2020 10:02:10

2K+ Views

To obtain the natural log of a number, we use the java.lang.Math.log() method. The Math.log() method returns the natural logarithm i.e. log to the base e of a double value. If the value passed is NaN or negative, the result is NaN. If the value passed is positive infinity, then the value returned is positive infinity. When the parameter is positive zero or negative zero, then negative infinity is returned.Declaration - The java.lang.Math.log() method is declared as followspublic static double log(double a)where a is a value whose natural logarithm is to be found.Let us see a program to get the ... Read More

Advertisements