It’s the because the null check is an implementation detail, not what the method logically does. Logically, the method checks whether the optional value is empty or engaged.

Technically, this can be implemented in a number of ways, depending on how the Optional stores its value. JDK 8’s implementation happens to use a reference object with a null check, but other implementations could conceivably do this differently. It’s a mistake to confuse a high-level interface description with its implementation. The entire point of encapsulation is to abstract away implementation details from the user.

Answer from Konrad Rudolph on Stack Overflow
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › util › Optional.html
Optional (Java SE 11 & JDK 11 )
January 20, 2026 - the non-null value described by ... false. Returns: true if a value is present, otherwise false · public boolean isEmpty() If a value is not present, returns true, otherwise false....
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › Optional.html
Optional (Java Platform SE 8 )
April 21, 2026 - If a value is present the result must include its string representation in the result. Empty and present Optionals must be unambiguously differentiable. ... Java™ Platform Standard Ed.
Top answer
1 of 4
7

It’s the because the null check is an implementation detail, not what the method logically does. Logically, the method checks whether the optional value is empty or engaged.

Technically, this can be implemented in a number of ways, depending on how the Optional stores its value. JDK 8’s implementation happens to use a reference object with a null check, but other implementations could conceivably do this differently. It’s a mistake to confuse a high-level interface description with its implementation. The entire point of encapsulation is to abstract away implementation details from the user.

2 of 4
4

You're missing the main point.

Optional is designed to be a container of data which can never be null by itself and which is safe to interact with.

Optional is not intended to be a substitution for null-checks. It's mean to represent a nullable return value and should not be creating in order to hide null-checks or chain methods on it (more on that, see here and here).

If you need to validate that something is not null you can use method Objects#requireNonNull() and it's flavors or explicit null-check.

The idea behind the optional, is that serves as a box for a value, and you can do whole lot of staff with it without caring if the box empty or not. Optional offers you methods to filter to the value inside the box filter(), to replace an empty box with another box or(), to transform the value inside the box map(), etc. And all these actions can be done by chaining the methods fluently without opening the box.

Methods isNull()/isNotNull() are not suitable for the Optional API because they contradict its design goal, which to provide a limited mechanism for representing a nullable return value and a mean of interaction with the target value (around which optional is wrapped) in a simple and fluent way regardless whether its value is null or not.

Note, that checks isPresent() (JDK 8) and isEmpty() (JDK 11) exist as a last resort. Be attentive when you're using them, because most likely you're not leveraging Optional to its full power.

Also, note that wrapping Optional around a Collection or an array doesn't make sense because they are container of data as well (like optional) and might be empty as well, which represents the absents of data.

Doing something like this is redundant and inconvenient.

CopyOptional<List<String>> optional = Optional.of(new ArrayList<>());

When a collection is not null, which should be the case because keeping nullable collections is an antipattern, Collection.isEmpty() is sufficient to check if the data is present. Meanwhile, when you have optional wrapped around collection, the presence of collection inside the optional doesn't means that the actual data is exists.

🌐
Educative
educative.io › answers › what-is-optionalisempty-in-java
What is Optional.isEmpty in Java?
In the third example, we create an Optional object from a null value. As the value passed is null, the method ofNullable replaces it with an empty Optional. Hence, the method isEmpty() returns true, indicating that the object doesn’t contain any value.
🌐
Baeldung
baeldung.com › home › java › core java › guide to java optional
Guide To Java Optional | Baeldung
February 15, 2026 - Sometimes, we may need to get the first non-empty Optional object from a number of Optional objects. In such cases, it would be very convenient to use a method like orElseOptional(). Unfortunately, such operation is not directly supported in Java 8.
🌐
Medium
medium.com › @JavaFusion › the-optional-class-in-java-8-469490077c0b
The Optional class in Java 8. The Optional class was introduced in… | by Java Fusion | Medium
April 1, 2024 - In Java’s Optional class, isPresent() and isEmpty() are methods used to check the presence of a value within an Optional object. It is typically used to perform actions on the value only if it is present, avoiding NullPointerException errors.
🌐
GeeksforGeeks
geeksforgeeks.org › java › optional-empty-method-in-java-with-examples
Optional empty() method in Java with examples - GeeksforGeeks
July 12, 2025 - Return value: This method returns an empty instance of this Optional class. Below programs illustrate empty() method: Program 1: ... // Java program to demonstrate // Optional.empty() method import java.util.*; public class GFG { public static void main(String[] args) { // create a Optional Optional<Integer> op = Optional.empty(); // print value System.out.println("Optional: " + op); } }
🌐
Medium
medium.com › @AlexanderObregon › javas-optional-empty-method-explained-67221fc67f96
Java’s Optional.empty() Method Explained | Medium
December 3, 2024 - The Optional.empty() method from the java.util.Optional class is a simple yet highly useful feature introduced in Java 8. It creates an empty Optional object that can represent the absence of a value.
Find elsewhere
🌐
DZone
dzone.com › coding › java › optional.isempty() coming to java?
Optional.isEmpty() Coming to Java?
April 19, 2018 - There is no JDK release currently associated with JDK-8184693, but it is being actively worked as demonstrated in a recent core-libs-dev mailing list post titled " RFR: 8184693: (opt) add Optional.isEmpty".
🌐
Laulem
laulem.com › en › dev › optional-usage-java-tutorial.html
Guide To Java Optional - LauLem.com
November 7, 2024 - After creating an Optional, we can check if it is empty or not (value contained is null) using the isEmpty method (from Java 11) and isPresent.
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › util › Optional.html
Optional (Java SE 21 & JDK 21)
January 20, 2026 - isEmpty() If a value is not present, returns true, otherwise false. boolean · isPresent() If a value is present, returns true, otherwise false. <U> Optional · <U> map · (Function<? super T, ? extends U> mapper) If a value is present, returns an Optional describing (as if by ofNullable(T)) ...
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › util › Optional.html
Optional (Java SE 17 & JDK 17)
April 21, 2026 - isEmpty() If a value is not present, returns true, otherwise false. boolean · isPresent() If a value is present, returns true, otherwise false. <U> Optional<U> map · (Function<? super T, ? extends U> mapper) If a value is present, returns an Optional describing (as if by ofNullable(T)) the ...
🌐
Blogger
marxsoftware.blogspot.com › 2018 › 07 › optional-isempty-jdk-11.html
Inspired by Actual Events: Optional.isEmpty() Available in JDK 11 EA Builds
The ! symbol is more easily missed when reading and reviewing code than is an explicitly named method such as "isEmpty()." Having such a method also aligns Optional's API for detecting "empty" more closely to that provided by String [String.isEmpty()],Collection [Collection.isEmpty()], and Map [Map.isEmpty()]. By · @DustinMarx at · July 21, 2018 · Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest · Labels: Java 11 ·
🌐
GitHub
github.com › openjdk › jdk › blob › master › src › java.base › share › classes › java › util › Optional.java
jdk/src/java.base/share/classes/java/util/Optional.java at master · openjdk/jdk
* {@code Optional.empty()}. There is no guarantee that it is a singleton. * Instead, use {@link #isEmpty()} or {@link #isPresent()}. * * @param <T> The type of the non-existent value ·
Author   openjdk
🌐
Oracle
docs.oracle.com › en › java › javase › 16 › docs › api › java.base › java › util › Optional.html
Optional (Java SE 16 & JDK 16)
January 6, 2022 - isEmpty() If a value is not present, returns true, otherwise false. boolean · isPresent() If a value is present, returns true, otherwise false. <U> Optional<U> map​(Function<? super T,​? extends U> mapper) If a value is present, returns an Optional describing (as if by ofNullable(T)) the ...
🌐
Oracle
docs.oracle.com › en › java › javase › 19 › docs › api › java.base › java › util › Optional.html
Optional (Java SE 19 & JDK 19)
December 12, 2022 - isEmpty() If a value is not present, returns true, otherwise false. boolean · isPresent() If a value is present, returns true, otherwise false. <U> Optional<U> map · (Function<? super T, ? extends U> mapper) If a value is present, returns an Optional describing (as if by ofNullable(T)) the ...
🌐
W3Schools
w3schools.io › java › java11-optional-isempty
java11 Optional isEmpty method Latest java features tutorials with examples - w3schools
December 31, 2023 - package java11; import java.util.Optional; public class OptionalIsEmptyTest { public static void main(String[] args) { String name= "john"; String department= null; System.out.println(Optional.ofNullable(name).isPresent()); // true System.out.println(Optional.ofNullable(department).isPresent()); //false System.out.println(Optional.ofNullable(name).isEmpty()); //false System.out.println(Optional.ofNullable(department).isEmpty()); //true // Check for department is null if(!Optional.ofNullable(department).isPresent()){ System.out.println("Department is null"); } // Check for name is not null if(Optional.ofNullable(name).isPresent()){ System.out.println("Name is not null"); } } }
🌐
Tabnine
tabnine.com › home › code library
Code Library - Tabnine
July 25, 2024 - Get the answers and suggestions you need from our AI code assistant. Get started in minutes with a free 90 day trial of Tabnine Pro.