約123件1ページ目

日本語のみで絞り込む

2018/8/27 -Using Optional as a return value avoids the problem of the caller accidentally misusing the sentinel value as the real return value. Given this, ...

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

2016/2/3 -As far as I can tell the most obvious difference is that the Optional requires creating an additional object. However, many people have started ...

2020/11/3 -By using Optional, we are avoiding null checks and can specify alternate values to return, thus making our code more readable.” But then the ...

2023/2/1 -Optional is a Java class that provides a way to handle null values in a type-safe and efficient manner. This tutorial will cover the ...

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.

2017/1/28 -Lately I see a lot of code like. Optional.ofNullable(i).ifPresent(x->doBla(x));. instead of a old known: if (i != null) { doBla(i); }.

2026/9/24 -The ofNullable() method of the Optional class creates an Optional containing the specified value when it is non-null. If the value is null, it ...

2026/4/13 -Using Optional.of() on a potentially null value. Optional.of(nullValue) throws NPE immediately — the opposite of what you want. Always use ...