日本語のみで絞り込む
2024/11/9 -Java's Optional class provides a safer way to handle potentially null values, making it possible to avoid the dreaded NullPointerException .
2016/2/11 -If a value is present, apply the provided mapping function to it, and if the result is non-null, return an Optional describing the result.
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.
2026/2/15 -The purpose of the class is to provide a type-level solution for representing optional values instead of null references. To get a deeper ...
2023/10/7 -Now, since this is for "modern" Java, I suppose the idiomatic way would be: return Optional.ofNullable(theFile).map(File::toPath).orElse(null);.
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 ...
2025/3/5 -I'm getting a false positive saying “map() can return null”, demonstrated with the following code: ... False Positive on `optional.orElse(null)`.
2026/4/13 -Any method that previously returned null to indicate "not found" is a candidate for Optional. Map.getOrDefault(key, defaultValue) and Map.
2024/8/7 -Learn how to use Java's Optional.ofNullable() method to handle null values safely, avoid NullPointerException, and write cleaner, ...
2025/12/8 -The map() method allows you to transform an Optional to an Optional of another value. The equivalent in Kotlin is let() . Since our example uses ...