1 Star 0 Fork 1

LiuYan/Java

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
OptionalOptimization.java 390 Bytes
Copy Edit Raw Blame History
liuyan authored 2023-06-30 16:27 +08:00 . code refactor
import java.util.Optional;
/**
* @author LiuYan
* @date 2023/5/8
*/
public class OptionalOptimization {
public static void main(String[] args) {
String str = null;
// orElseThrow():Exception in thread "main" java.util.NoSuchElementException: No value present
String newStr= Optional.ofNullable(str).orElseThrow();
System.out.println(newStr);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/Liu-Yan-Code/java.git
git@gitee.com:Liu-Yan-Code/java.git
Liu-Yan-Code
java
Java
master

Search