相关信息
Brian Goetz (Java语言设计架构师)对 Optional 设计意图的解释:
Optional is intended to provide a limited mechanism for library method return types where there needed to be a clear way to represent “no result," and using null for such was overwhelmingly likely to cause errors.
从中可以看出,Optional 主要目的是用于处理返回值可能为空的情况。
2023/10/12