日本語のみで絞り込む
2015/2/26 -In Java 8 you can return an Optional instead of a null . Java 8 documentation says that an Optional is "A container object which may or may ...
2017/6/14 -If null handling is very important, use an Optional. If null is a valid return that does not indicate unavailability or failure, use an Optional ...
2020/11/3 -The main point of Optional is to indicate the absence of a value (i.e null value ) while returning value for the function. It was meant to ...
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 ...
2026/4/13 -Optional is not a null eliminator — it is an API contract: a method that returns Optional<T> is telling callers explicitly that no value may ...
However, the advantage compared to null references is that the Optional class forces you to think about the case when the value is not present. As a consequence ...
Because with Optional the type tells the caller that it might not return a value. With null, you have no idea if you need to check for null or not. Being able ...
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 ...
2018/6/23 -Therefore, you are better off using a regular possibly-null Java reference, rather than using Optional . ... if the value is null, return null ...
2014/6/13 -Suppose that null didn't exist, then you'd immediately see by looking at the method declaration if it could ever return "no value" - the method ...