[JAVA] Optional 잘 사용하는 방법


[JAVA] Optional 잘 사용하는 방법

Java 언어 설계자인 Brain Goetz는 Optional을 만든 의도를 아래와 같이 작성했다. API Note: Optional is primarily intended for use as a method return type where there is a clear need to represent "no result," and where using null is likely to cause errors. A variable whose type is Optional should never itself be null; it should always point to an Optional instance. 메소드가 반환할 결과 값이 '없음'을 명백하게 표현할 필요가 있고, null 을 반환하면 에러가 발생..


원문링크 : [JAVA] Optional 잘 사용하는 방법