約107件1ページ目

日本語のみで絞り込む

2017/1/13 -i.e. if some object is not null, I need to call an object method and return its result, or else return 0. Optional.ofNullable().orElse() is not ...

2023/7/24 -We can create an Optional instance using the of() method if we are sure the value is non-null. If the value passed to of() is null, it will ...

2024/6/12 -The whole purpose of Optional is to represent method return values that may be null. Drives me nuts to see it used as a glorified null check.

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

2022/2/6 -A look at how Optional works, and how it isn't really about Null values - at least not if you were doing it right before Optional.

2023/2/1 -By wrapping a potentially null value in an Optional, you can safely access the value without risking a NullPointerException. For example, if you ...

2021/5/27 -Optionals are often used unnecessarily as tools to perform local null checks instead of using regular if-else statements.

2024/9/7 -ofNullable(T value): Creates an Optional that may hold a null value. isPresent(): Checks if there is a non-null value inside the Optional.

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

2018/1/18 -The Optional is meant to help document that something may or may not return a value. You might get nothing. This has led you do write perfectly ...