約17,600件1ページ目

日本語のみで絞り込む

2021/6/15 -A variable whose type is Optional should never itself be null; it should always point to an Optional instance.” The primary intended use ...

2024/9/7 -In the refactored code, the ofNullable() method is used to create an Optional that may or may not contain the object obj . If obj is null , an ...

2022/4/12 -If the given object is nullable by its nature, i.e. null isn't an abnormal case, then use Optional.ofNullable() , it'll fire either a box ...

2024/3/17 -Java 9 has added an or() method that we can use to get an Optional, or another value, if that Optional isn't present. Let's see this in practice ...

The ofNullable() method returns an Optional that holds the value. If the value is null , it returns an empty Optional . Use it when the value can be null , for ...

ofNullable. public static <T> Optional<T> ofNullable(T value). Returns an Optional describing the specified value, if non-null, otherwise returns an empty ...

2020/8/31 -I consider it more as a preference or inclination for Java features. I mean, calling ofNullable has a time and space cost (passing params by ...

2024/12/15 -Guide to java.util.Optional in modern Java—avoid NullPointerExceptions with ofNullable(), orElseGet(), map(), filter(), and functional ...

2025/4/7 -Optional.of() is the 'constructor' to make the SOME variant. Given that it is not possible to construct the SOME variant with a null value, ...

2024/8/7 -The Optional.ofNullable() method is used to create an Optional object that may or may not contain a value. It takes a single argument, which can ...