OptionalDouble isPresent() method in Java with examples Last Updated : 01 May, 2019 Comments Improve Suggest changes Like Article Like Report OptionalDouble help us to create an object which may or may not contain a Double value. The isPresent() method help us to get the answer that double value is present in OptionalDouble object or not. If a double value is present, returns true, otherwise false. Syntax: public boolean isPresent() Parameters: This method accepts nothing. Return value: This method returns true if a value is present, otherwise false Below programs illustrate isPresent() method: Program 1: Java // Java program to demonstrate // OptionalDouble.isPresent() method import java.util.OptionalDouble; public class GFG { public static void main(String[] args) { // create a OptionalDouble OptionalDouble opDouble = OptionalDouble.of(3148.1345); // get value using isPresent() System.out.println("OptionalDouble" + " has a value= " + opDouble.isPresent()); } } Output: OptionalDouble has a value= true Program 2: Java // Java program to demonstrate // OptionalDouble.isPresent() method import java.util.OptionalDouble; public class GFG { public static void main(String[] args) { // create a OptionalDouble OptionalDouble opDouble = OptionalDouble.empty(); // try to get that value is present or not boolean response = opDouble.isPresent(); if (response) System.out.println("Value present"); else System.out.println("Value absent"); } } Output: Value absent References: https://docs.oracle.com/javase/10/docs/api/java/util/OptionalDouble.html#isPresent() Comment More infoAdvertise with us Next Article OptionalDouble isPresent() method in Java with examples A AmanSingh2210 Follow Improve Article Tags : Java Java - util package Java-Functions Java-OptionalDouble Practice Tags : Java Similar Reads OptionalLong isPresent() method in Java with examples OptionalLong help us to create an object which may or may not contain a Long value. The isPresent() method help us to get the answer that a value is present in OptionalLong object or not. If a long value is present in this object, this method returns true, otherwise false. Syntax: public boolean isP 1 min read OptionalInt isPresent() method in Java with examples OptionalInt help us to create an object which may or may not contain a Int value. The isPresent() method help us to get the answer that Int value is present in OptionalInt object or not. If an int value is present in this object, this method returns true, otherwise false. Syntax: public boolean isPr 1 min read OptionalDouble ifPresentOrElse() method in Java with examples The ifPresentOrElse(java.util.function.DoubleConsumer, java.lang.Runnable) method helps us to perform the specified DoubleConsumer action the value of this OptionalDouble object. If a value is not present in this OptionalDouble, then this method performs the given empty-based Runnable emptyAction, p 2 min read OptionalInt orElse(int) method in Java with examples The orElse(int) method helps us to get the value in this OptionalInt object. If a value is not present in this OptionalInt, then this method returns the value passed as the parameter. Syntax: public int orElse(int other) Parameters: This method accepts int the value to be returned, if no value is pr 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 Like