OptionalLong empty() method in Java with examples Last Updated : 11 Apr, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report OptionalLong help us to create an object which may or may not contain a Long value. The empty() method returns an empty OptionalLong instance. No value is present for this OptionalLong. So we can say that this method help us to create empty OptionalLong object. Syntax: public static OptionalLong empty() Parameters: This method accepts nothing. Return value: This method returns an empty OptionalLong. Below programs illustrate empty() method: Program 1: Java // Java program to demonstrate // OptionalLong.empty() method import java.util.OptionalLong; public class GFG { public static void main(String[] args) { // create a OptionalLong // using empty method OptionalLong opLong = OptionalLong.empty(); // print OptionalLong System.out.println("OptionalLong: " + opLong.toString()); } } Output:OptionalLong: OptionalLong.empty References: https://docs.oracle.com/javase/10/docs/api/java/util/OptionalLong.html#empty() Comment More infoAdvertise with us Next Article OptionalInt empty() method in Java with examples A AmanSingh2210 Follow Improve Article Tags : Java Java - util package Java-Functions Java-OptionalLong Practice Tags : Java Similar Reads Optional empty() method in Java with examples The empty() method of java.util.Optional class in Java is used to get an empty instance of this Optional class. This instance do not contain any value. Syntax: public static <T> Optional<T> empty() Parameters: This method accepts nothing. Return value: This method returns an empty instan 1 min read Optional empty() method in Java with examples The empty() method of java.util.Optional class in Java is used to get an empty instance of this Optional class. This instance do not contain any value. Syntax: public static <T> Optional<T> empty() Parameters: This method accepts nothing. Return value: This method returns an empty instan 1 min read OptionalInt empty() method in Java with examples OptionalInt help us to create an object which may or may not contain a int value. The empty() method returns an empty OptionalInt instance. No value is present for this OptionalInt. So we can say that this method help us to create empty OptionalInt object. Syntax: public static OptionalInt empty() P 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 Optional or() method in Java with examples The or() method of java.util.Optional class in Java is used to get this Optional instance if any value is present. If there is no value present in this Optional instance, then this method returns an Optional instance with the value generated from the specified supplier. Syntax: public Optional<T 2 min read Optional or() method in Java with examples The or() method of java.util.Optional class in Java is used to get this Optional instance if any value is present. If there is no value present in this Optional instance, then this method returns an Optional instance with the value generated from the specified supplier. Syntax: public Optional<T 2 min read Like