if 식 또는 조건식의 조건으로 사용되고 함수 형태로 다시 작성될 수 있는Optional 식을 보고합니다. 이러면 결과가 더 짧고 읽기 쉬워지는 경우가 많습니다.

예:


  if (str.isPresent()) str.get().trim();

빠른 수정을 적용한 후:


  str.ifPresent(String::trim);