Java floor() method with Examples Last Updated : 04 Apr, 2023 Comments Improve Suggest changes Like Article Like Report The java.lang.Math.floor() returns the double value that is less than or equal to the argument and is equal to the nearest mathematical integer. Note: If the argument is Integer, then the result is Integer.If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument. public static double floor(double a) a : the argument whose floor value is to be determined Returns : This method returns the double value that is less than or equal to the argument and is equal to the nearest mathematical integer. Example 01:To show working of java.lang.Math.floor() method. java // Java program to demonstrate working // of java.lang.Math.floor() method import java.lang.Math; class Gfg { // Main driver code public static void main(String args[]) { double a = 4.3; double b = 1.0 / 0; double c = 0.0; double d = -0.0; double e = -2.3; System.out.println(Math.floor(a)); // Input Infinity, Output Infinity System.out.println(Math.floor(b)); // Input Positive Zero, Output Positive Zero System.out.println(Math.floor(c)); // Input Negative Zero, Output Negative Zero System.out.println(Math.floor(d)); // Input -2.3, Output -3.0 // Nearest Integer(-3.0) < less than (-2.3) System.out.println(Math.floor(e)); } } Output: 4.0 Infinity 0.0 -0.0 -3.0 Example 02:To show the working of floor() with a positive double value. Java import java.io.*; class GFG { public static void main(String[] args) { double number = 3.5; // double num-3.5 double result = Math.floor(number); System.out.println(result); // Output: 3.0 } } Output : 3.0 Comment More infoAdvertise with us Next Article Java floor() method with Examples N Niraj_Pandey Follow Improve Article Tags : Java Technical Scripter Java-Library java-math Practice Tags : Java Similar Reads Field get() method in Java with Examples The get() method of java.lang.reflect.Field used to get the value of the field object. If Field has a primitive type then the value of the field is automatically wrapped in an object. If the field is a static field, the argument of obj is ignored; it may be null Otherwise, the underlying field is an 3 min read Field set() method in Java with Examples The set() method of java.lang.reflect.Field is used to set the value of the field represented by this Field object on the specified object argument to the specified new value passed as parameter. The new value is automatically unwrapped if the underlying field has a primitive type. If the field is s 4 min read Period from() method in Java with Examples The from() method of Period class in Java is used to get an instance of Period from given temporal amount. This function obtains a period based on the amount given in argument. A TemporalAmount represents an amount of time, which may be date-based or time-based. Syntax: public static Period from(Tem 1 min read Static Method in Java With Examples In Java, the static keyword is used to create methods that belongs to the class rather than any specific instance of the class. Any method that uses the static keyword is referred to as a static method.Features of Static Method:A static method in Java is associated with the class, not with any objec 3 min read Year of() method in Java with Examples The of() method of Year class in Java is used to return an Year instance. It accepts an year according to the proleptic ISO calendar system and returns an instance of Year with the specified isoYear. Syntax: public static Year of(int isoYear) Parameter: It accepts a single integral value isoYear as 1 min read Like