< prev index next >
src/java.base/share/classes/java/util/OptionalInt.java
Print this page
@@ -138,10 +138,20 @@
public boolean isPresent() {
return isPresent;
}
/**
+ * If a value is not present, returns {@code true}, otherwise
+ * {@code false}.
+ *
+ * @return {@code true} if a value is not present, otherwise {@code false}
+ */
+ public boolean isEmpty() {
+ return !isPresent;
+ }
+
+ /**
* If a value is present, performs the given action with the value,
* otherwise does nothing.
*
* @param action the action to be performed, if a value is present
* @throws NullPointerException if value is present and the given action is
< prev index next >