当前位置:网站首页>消除`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");
边栏推荐
猜你喜欢

EPM related

統計php程序運行時間及設置PHP最長運行時間

Zabbix

GFS分布式文件系统

flask接口响应中的中文乱码(unicode)处理

IDC report: Tencent cloud database ranks top 2 in the relational database market!

ISPRS2022/云检测:Cloud detection with boundary nets基于边界网的云检测

Abnormal recovery of virtual machine Oracle -- Xi Fenfei

Six bad safety habits in the development of enterprise digitalization, each of which is very dangerous!

Server configuration jupyter environment
随机推荐
flask接口响应中的中文乱码(unicode)处理
Seven Devops practices to improve application performance
Leetcode daily question: the first unique character in the string
Knowledge points of MySQL (7)
"Xiaodeng in operation and maintenance" is a single sign on solution for cloud applications
VC编程入门浅谈「建议收藏」
通过SOCKS代理渗透整个内网
Ordinary programmers look at the code, and top programmers look at the trend
mybash
Sentinel flow guard
The comprehensive competitiveness of Huawei cloud native containers ranks first in China!
Interpretation: how to deal with the current security problems faced by the Internet of things?
Read libco save and restore the on-site assembly code
7 pratiques devops pour améliorer la performance des applications
Binder开辟线程数过多导致主线程ANR异常
EasyCVR接入设备开启音频后,视频无法正常播放是什么原因?
RSE2020/云检测:基于弱监督深度学习的高分辨率遥感图像精确云检测
Tkinter window preload
QT控制台打印输出
证券网上开户安全吗?证券融资利率一般是多少?