- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4335 Articles for Java 8
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
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
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
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
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
379 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
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
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
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
1K+ Views
To obtain the maximum of two numbers using Math.max in Java, we use the java.lang.Math.max() method. The Math.max() accepts two numbers and returns the greater of the two. The result is closer to positive infinity on the number line. Even if one of the values is not a number(NaN), the result is NaN.Declaration - The java.lang.Math.max() method is declared as follows −public static int max(int a, int b) public static double max(double a, double b) public static long max(long a, long b) public static float max(float a, float b)Let us see a program to get the maximum of two numbers ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
461 Views
To get the floor value of a number, we use the java.lang.Math.floor() method. The Math.floor() method returns the largest (closest to positive infinity) double value which is less than or equal to the parameter and has a value which is equal to a mathematical integer on the number line. If the parameter is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.Declaration - The java.lang.Math.floor() method is declared as follows −public static double floor(double a)Let us see a program to get the floor value of a number in Java.Example Live Demoimport ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
1K+ 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)where 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 ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
3K+ Views
To get the exponential value of a number in Java, we use the java.lang.Math.exp() method. The Math.exp() returns a double value which is the Euler’s number e raised to the power of the argument. If the parameter is NaN, the result obtained is NaN. If the argument is positive infinity, then the result is positive infinity. In case the argument is negative infinity, then the output is positive zero.Declaration − The java.lang.Math.exp() method is declared as follows:public static double exp(double a)where a is the number representing the power to which e is raised to.Let us see a program to get ... Read More
![Nancy Den](https://www.tutorialspoint.com/assets/profiles/13557/profile/60_88439-1512714529.jpg)
1K+ Views
In order to get the ceiling value of a number in Java, we use the java.lang.Math.ceil() method. The Math.ceil() method returns the smallest (closest to negative infinity) double value which is greater than or equal to the parameter and has a value which is equal to a mathematical integer on the number line. If the parameter is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument. If the argument value is less than zero but greater than -1.0, then the value returned is negative zero.Declaration − The java.lang.Math.ceil() method is ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
820 Views
The java.lang.Math class has an abs() method which facilitates us to find the absolute values of different data types.Absolute value of floatIn order to compute the absolute value of a float value, we use the java.lang.Math.abs(float a) method. If the argument ‘a’ is negative, the negation of ‘a’ is returned. If the argument ‘a’ is non-negative, the argument itself is returned. When the argument is positive zero or negative zero, the result is positive zero. In case the argument is infinite, the result is positive infinity. If the argument is NaN, the result is NaN.Declaration − The declaration of Math.abs(float ... Read More