我正在试着做这样的东西: private String getStringIfObjectIsPresent(Optional<Object> object){ //some logic with result and return it }).orElseThrow(MyCustomException::new);
} 这不会起作用,因
我有一段不安全的代码,它可能引发nullPtr异常:如何使用java 8可选和如果当前()安全地返回最少数量的代码(// How can I modify this to return from the ifPresent()...or a better way in
// java8?how can I just return a string from the if