約122件1ページ目

日本語のみで絞り込む

2017/3/24 -How to use Java 8 Optional properly that can conditionally return a value or throw exception? 5 · Throw exception if Optional<> value is present ...

2024/1/8 -Optional.orElseThrow() Method. Simply put, if the value is present, then isPresent() returns true, and calling get() returns this value.

2024/5/21 -The rule is that you throw exceptions in exceptional circumstances. For example, if the user enters a part number and you look up information ...

2025/7/12 -The orElseThrow() method of java.util.Optional class in Java is used to get the value of this Optional instance if present.

2022/2/19 -Optional isn't a replacement for checked exceptions, it's a replacement for null return values. Like null , Optional doesn't tell you why a ...

2020/8/31 -Throwing exceptions should be reserved for truly exceptional conditions and furthermore exceptions make the caller code boilerplate (in case of ...

If something is wrong, throw an exception. If it's the kind of error that must be handled, throw a checked exception. If there's no value to return, return ...

Ideally, we could handle exceptions functionally the same way Optional lets us deal with null . This would allow us to use APIs that throw checked exceptions ...

If a value is present in this Optional , returns the value, otherwise throws NoSuchElementException . Returns: the non-null value held by this Optional; Throws: ...

2026/2/10 -orElseThrow() extracts the value from an Optional when it is present and throws an exception when the Optional is empty. The no-argument version ...