当前位置:网站首页>消除`if()else{ }`写法
消除`if()else{ }`写法
2022-07-05 17:47:00 【Edric_豪】
- 如果
person
的名称为空,则执行业务赋值ID
Person person = new Person();
Optional.ofNullable(person..getName()).ifPresent(p->p.setId(1))
- 如果
person
的名称不为空则返回名称,否则返回2
String test = Optional.ofNullable(person.getName()).orElse("2");
边栏推荐
猜你喜欢
GFS分布式文件系统
EPM相关
Cmake tutorial Step4 (installation and testing)
修复漏洞 - mysql 、es
每日一练:关于日期的一系列
Cmake tutorial step1 (basic starting point)
Thesis reading_ Chinese NLP_ LTP
寻找第k小元素 前k小元素 select_k
Leetcode daily question: the first unique character in the string
Configure pytorch environment in Anaconda - win10 system (small white packet meeting)
随机推荐
十个顶级自动化和编排工具
Cartoon: interesting pirate problem (full version)
leetcode每日一题:字符串中的第一个唯一字符
Leetcode daily question: merge two ordered arrays
GFS distributed file system
Leetcode daily question: the first unique character in the string
ISPRS2022/云检测:Cloud detection with boundary nets基于边界网的云检测
企业数字化发展中的六个安全陋习,每一个都很危险!
通过SOCKS代理渗透整个内网
Webapp development - Google official tutorial
Cmake tutorial step1 (basic starting point)
rsync
Abnormal recovery of virtual machine Oracle -- Xi Fenfei
使用QT设计师界面类创建2个界面,通过按键从界面1切换到界面2
IDC report: Tencent cloud database ranks top 2 in the relational database market!
EPM相关
Cartoon: interesting [pirate] question
Matlab reference
修复漏洞 - mysql 、es
Size_t 是无符号的