約5,450,000件1ページ目

日本語のみで絞り込む

2018/8/27 -If you expect a null to possibly arrive, and have an alternative instance available as a fall-back option, use Optional::orElse . If the fall- ...

2024/1/16 -The API of Optional typically has two methods that can cause confusion: orElse() and orElseGet(). In this quick tutorial, we'll look at the ...

2024/9/7 -Since null is passed as the argument, the Optional is effectively empty—it doesn't contain any value. When the orElse() method is invoked on ...

2018/8/29 -In java when you are working with Optional and you want to pass the value where Optional is not supported you do value = optional.orElse(null) .

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

2026/9/10 -The orElseGet() method of the Optional class returns the value stored in the Optional when it is present. When the Optional is empty, ...

Avoid Using null for Optionals: When you have a variable or a method that may or may not have a value, it's a best practice to use the Optional class to wrap ...

2015/10/13 -My first idea was to use Optional with the intention of being able to handle the 'null' condition more gracefully and in the hope it would ...

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.

2022/1/13 -How to replace imperative code with a functional style, when returning a default value for a Java `Optional`.