約106件1ページ目

日本語のみで絞り込む

2018/8/27 -If you absolutely expect there always to be a value, then use Optional::orElseThrow to throw an Exception if a null appears. If you expect a ...

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

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

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

Optional is primarily intended for use as a method return type where there is a clear need to represent "no result," and where using null is likely to cause ...

2024/12/15 -Using orElseThrow() is a good way to ensure that your code fails fast if an expected value is missing, rather than continuing with a null value ...

2023/1/26 -Pass null as an argument to orElse in the Java Optional API: Optional.of(<anything>).map(<anyFunction>).orElse(null). Example of how to ...

2023/2/1 -Optional can also be used to define default values for missing or null values. You can use Optional.orElse() to specify a default value to ...

2025/1/16 -`Optional` is a container object used to represent the presence or absence of a value. Rather than returning `null` for missing values, you can ...