約107件1ページ目

日本語のみで絞り込む

2016/11/24 -By explicitly returning an Optional, the caller of someFunc() is made aware that the interface could potentially return null. From an interface ...

2024/12/3 -The Optional.empty() method provides a straightforward way to create an Optional object that contains no value. It eliminates the need for null ...

2016/2/3 -Optional is used with the convention that methods with return type Optional never return null and usually also with the (less strong) convention ...

2026/2/15 -This code checks if the name variable is null or not before going ahead to execute some code on it. This approach is lengthy, and that's not the ...

2025/12/10 -I'm currently refactoring a Java application to improve its handling of null values. I've come across the Optional class and would like to ...

2024/1/1 -Using Optional expresses the intent more clearly: “I want the first item of the list if it is present and not empty.” Separates the null check, ...

2023/2/1 -In this example, we created an Optional from a potentially null value. We then use the Optional.isPresent() method to check if the value is ...

2023/7/24 -We can create an Optional instance using the of() method if we are sure the value is non-null. If the value passed to of() is null, it will ...

2015/10/13 -By the way, instead of Optional.ofNullable(null) you could just write Optional.empty().

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.