VOOZH about

URL: https://www.geeksforgeeks.org/java/optional-empty-method-in-java-with-examples/

⇱ Optional empty() method in Java with examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Optional empty() method in Java with examples

Last Updated : 12 Jul, 2025
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 instance of this Optional class. Below programs illustrate empty() method: Program 1:
Output:
Optional: Optional.empty
Program 2:
Comment