OptionalInt empty() method in Java with examples Last Updated : 22 Sep, 2021 Comments Improve Suggest changes Like Article Like Report 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() Parameters: This method accepts nothing.Return value: This method returns an empty OptionalInt. Below programs illustrate empty() method: Program 1: Java // Java program to demonstrate // OptionalInt.empty() method import java.util.OptionalInt; public class GFG { public static void main(String[] args) { // create a OptionalInt // using empty method OptionalInt opInt = OptionalInt.empty(); // Print the created instance System.out.println("OptionalInt: " + opInt.toString()); } } Output: OptionalInt: OptionalInt.empty References: https://docs.oracle.com/javase/10/docs/api/java/util/OptionalInt.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-OptionalInt 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 OptionalLong empty() method in Java with examples 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 emp 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 equals() method in Java with Examples The equals() method of java.util.Optional class in Java is used to check for equality of this Optional with the specified Optional. This method takes an Optional instance and compares it with this Optional and returns a boolean value representing the same. Syntax: public boolean equals(Object obj) P 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 Like