OptionalDouble of(double) method in Java with examples Last Updated : 02 May, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The of(double) method help us to get an OptionalDouble object which contains a double value which is passed as a parameter to this method. Syntax: public static OptionalDouble of(double value) Parameters: This method accepts a double value as parameter that will be set to the returned OptionalDouble object. Return value: This method returns an OptionalDouble with the value present. Below programs illustrate of(double) method: Program 1: Java // Java program to demonstrate // OptionalDouble.of(double) method import java.util.OptionalDouble; public class GFG { public static void main(String[] args) { // Create a OptionalDouble instance // using of() method OptionalDouble opDouble = OptionalDouble.of(45213.246); // Get value of this OptionalDouble instance System.out.println("OptionalDouble: " + opDouble); } } Output: OptionalDouble: OptionalDouble[45213.246] Program 2: Java // Java program to demonstrate // OptionalDouble.of(double) method import java.util.OptionalDouble; public class GFG { public static void main(String[] args) { // Create a OptionalDouble instance // using of() method OptionalDouble opDouble = OptionalDouble.of(21438999); // Get value of this OptionalDouble instance System.out.println("OptionalDouble: " + opDouble); } } Output: OptionalDouble: OptionalDouble[2.1438999E7] References: https://docs.oracle.com/javase/10/docs/api/java/util/OptionalDouble.html#of(double) Comment More infoAdvertise with us Next Article Double parseDouble() method in Java with examples A AmanSingh2210 Follow Improve Article Tags : Java Java - util package Java-Functions Java-OptionalDouble Practice Tags : Java Similar Reads OptionalDouble orElse(double) method in Java with examples The orElse(double) method helps us to get the value in this OptionalDouble object. If a value is not present in this OptionalDouble, then this method returns the value passed as the parameter. Syntax: public double orElse(double other) Parameters: This method accepts double the value to be returned, 1 min read OptionalDouble empty() method in Java with examples OptionalDouble help us to create an object which may or may not contain a Double value. The empty() method returns an empty OptionalDouble instance. No value is present for this OptionalDouble. So we can say that this method help us to create empty OptionalDouble object. Syntax: public static Option 1 min read Double parseDouble() method in Java with examples The parseDouble() method of Java Double class is a built in method in Java that returns a new double initialized to the value represented by the specified String, as done by the valueOf method of class Double. Syntax: public static double parseDouble(String s) Parameters: It accepts a single mandato 2 min read Double parseDouble() method in Java with examples The parseDouble() method of Java Double class is a built in method in Java that returns a new double initialized to the value represented by the specified String, as done by the valueOf method of class Double. Syntax: public static double parseDouble(String s) Parameters: It accepts a single mandato 2 min read Optional of() method in Java with examples The of() method of java.util.Optional class in Java is used to get an instance of this Optional class with the specified value of the specified type. Syntax: public static <T> Optional<T> of(T value) Parameters: This method accepts value as parameter of type T to create an Optional insta 1 min read Optional of() method in Java with examples The of() method of java.util.Optional class in Java is used to get an instance of this Optional class with the specified value of the specified type. Syntax: public static <T> Optional<T> of(T value) Parameters: This method accepts value as parameter of type T to create an Optional insta 1 min read Like