約107件1ページ目

日本語のみで絞り込む

2016/6/27 -You could use orElse(null) : String o = getOptional().orElse(null); if (o == null) { return; }.

2024/12/3 -Learn how Java's Optional.empty() method creates empty optional objects, helps avoid null, and improves code safety with examples and best ...

2026/2/20 -Getting an empty Optional out of null is straightforward — we just use Optional.ofNullable(). But, what if we want empty Strings to work this ...

2025/12/10 -The key goal is to return a value wrapped in an Optional to explicitly signal that it might be absent. This avoids returning null directly and ...

Returns an Optional describing the specified value, if non-null, otherwise returns an empty Optional . Type Parameters: T - the class of the value; Parameters: ...

2026/4/13 -Optional<T> is a container class with two states: present (wraps a non-null value) and empty (wraps nothing). It was introduced in Java 8 as a ...

2023/2/1 -You can use Optional.orElse() to specify a default value to return if the Optional is empty. This can make your code more resilient and reduce ...

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

Optional.empty() gets you an hold of empty optional object. The default values for the nullable members of an object can be of this type which passed ...

you can usually simply return an empty object instead of null , and it will work fine, without special handling. In these cases, there's usually no need for the ...