🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › Optional.html
Optional (Java Platform SE 8 )
April 21, 2026 - public final class Optional<T> extends Object · A container object which may or may not contain a non-null value. If a value is present, isPresent() will return true and get() will return the value.
🌐
Baeldung
baeldung.com › home › java › core java › guide to java optional
Guide To Java Optional | Baeldung
February 15, 2026 - @Test public void givenOptional_whenIsPresentWorks_thenCorrect() { Optional<String> opt = Optional.of("Baeldung"); assertTrue(opt.isPresent()); opt = Optional.ofNullable(null); assertFalse(opt.isPresent()); }
🌐
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 - public final class Optional<T> extends Object · A container object which may or may not contain a non-null value. If a value is present, isPresent() returns true. If no value is present, the object is considered empty and isPresent() returns false.
🌐
DZone
dzone.com › coding › languages › optional ispresent() is bad for you
Optional isPresent() Is Bad for You
October 1, 2016 - final Optional<Person> bigPerson = members.stream() .filter(member -> member.getLevel() > 10) .findFirst(); if (bigPerson.isPresent()) { //many lines of code here return something; } else { return another; }
🌐
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.
🌐
Java67
java67.com › 2018 › 06 › java-8-optional-example-ispresent-orElse-get.html
Java 8 Optional isPresent(), OrElse() and get() Examples | Java67
package tool; import java.util.Arrays; import java.util.List; import java.util.Optional; /** * Program to demonstrate how to use Optional in Java 8 * * @author WINDOWS 8 * */ public class Hello { private static List<String> listOfBooks = Arrays.asList("Effective Java", "Clean Code", "Test Driven"); /* * Return the first book start with a letter. */ public static String getBook(String letter) { Optional<String> book = listOfBooks.stream() .filter(b -> b.startsWith(letter)) .findFirst(); return book.isPresent() ?
🌐
GeeksforGeeks
geeksforgeeks.org › optional-ispresent-method-in-java-with-examples
Optional isPresent() method in Java with examples | GeeksforGeeks
July 30, 2019 - The isPresent() method of java.util.Optional class in Java is used to find out if there is a value present in this Optional instance.
🌐
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 - public final class Optional<T> extends Object · A container object which may or may not contain a non-null value. If a value is present, isPresent() returns true. If no value is present, the object is considered empty and isPresent() returns false.
Find elsewhere
🌐
Apps Developer Blog
appsdeveloperblog.com › home › java › functional programming in java › optional – ifpresent() and ispresent() methods
Optional - ifPresent() and isPresent() methods - Apps Developer Blog
August 10, 2022 - The isPresent() method returns true if there is a value present in the Optional, otherwise false. Using it, we can avoid getting an exception when trying to get the value from an empty Optional.
🌐
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 - public final class Optional<T> extends Object · A container object which may or may not contain a non-null value. If a value is present, isPresent() returns true. If no value is present, the object is considered empty and isPresent() returns false.
🌐
j-labs
j-labs.pl › home › tech blog › how to use and how not to use optional in java
How to use and how not to use Optional in Java | j‑labs
February 11, 2025 - ofNullable(T value) Returns an Optional describing the specified value, if non-null, otherwise returns an empty Optional. isPresent() Return true if there is a value present, otherwise false.
🌐
Educative
educative.io › answers › what-is-the-optionalispresent-method-in-java
What is the Optional.isPresent method in Java?
In Java, the Optional object is a container object that may or may not contain a value. Using the Optional object’s isPresent method, we can replace the multiple null check.
🌐
Globalmentor
globalmentor.com › courses › softdev › optionals
Optionals
When using Optional<T> you can avoid a NoSuchElementException as you would avoid a NullPointerException: by first checking if a value is present before continuing processing. The Optional.isPresent() method indicates whether the Optional<T> instance contains a value, and can be used wherever ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › optional-class-ispresent-function
Optional Class | isPresent() function - GeeksforGeeks
February 22, 2018 - The isPresent() function in Optional Class is used to evaluate whether the value if assigned to variable is present or not.
🌐
Oracle
docs.oracle.com › javase › 9 › docs › api › java › util › Optional.html
Optional (Java SE 9 & JDK 9 )
If a value is present, isPresent() returns true and get() returns the value. Additional methods that depend on the presence or absence of a contained value are provided, such as orElse() (returns a default value if no value is present) and ifPresent() (performs an action if a value is present).
🌐
LinkedIn
linkedin.com › pulse › optional-java-8-example-terala-chittibabu
Optional in Java 8 with example
July 12, 2022 - Optional<String> o = Optional.empty(); // check if optional contains a value if(o.isPresent()) { System.out.print(o.get()); }
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.util.optional.ispresent
Optional.IsPresent Property (Java.Util) | Microsoft Learn
[<get: Android.Runtime.Register("isPresent", "()Z", "", ApiSince=24)>] member this.IsPresent : bool ... If a value is present, returns true, otherwise false. Java documentation for java.util.Optional.isPresent().
🌐
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 - public final class Optional<T> extends Object · A container object which may or may not contain a non-null value. If a value is present, isPresent() returns true. If no value is present, the object is considered empty and isPresent() returns false.
🌐
Hackajob
hackajob.com › talent › blog › using-the-optional-feature-in-java-8
Using the Optional Feature in Java 8
October 9, 2023 - The 'Optional.isPresent' method can be used to check if a value is present within the 'Optional' object. If a value is true, it returns a present, otherwise it returns a false.