約120件1ページ目

日本語のみで絞り込む

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 ...

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 ...

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 ...

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

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 ...

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/1/16 -orElse(): returns the value if present, otherwise returns other; orElseGet(): returns the value if present, otherwise invokes other and returns ...

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 ...

2023/4/15 -This is because internally Optional.ofNullable with a null value, will short-circuit to an empty Optional : public static <T> Optional<T> ...