当前位置:网站首页>消除`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");
边栏推荐
- The five most difficult programming languages in the world
- 提高应用程序性能的7个DevOps实践
- flask接口响应中的中文乱码(unicode)处理
- EasyCVR接入设备开启音频后,视频无法正常播放是什么原因?
- Six bad safety habits in the development of enterprise digitalization, each of which is very dangerous!
- Please tell me why some tables can find data by writing SQL, but they can't be found in the data map, and the table structure can't be found
- Cmake tutorial Step4 (installation and testing)
- Oracle recovery tools -- Oracle database recovery tool
- Anaconda中配置PyTorch环境——win10系统(小白包会)
- matlab内建函数怎么不同颜色,matlab分段函数不同颜色绘图
猜你喜欢

「运维有小邓」用于云应用程序的单点登录解决方案

求解为啥all(())是True, 而any(())是FALSE?

LeetCode 练习——206. 反转链表

每日一练:关于日期的一系列

Leetcode exercise - 206 Reverse linked list

GFS distributed file system

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

Count the running time of PHP program and set the maximum running time of PHP

leetcode每日一练:旋转数组

IDC report: Tencent cloud database ranks top 2 in the relational database market!
随机推荐
[performance test] full link voltage test
请问下为啥有的表写sql能查到数据,但在数据地图里查不到啊,查表结构也搜不到
Vulnerability recurrence - 48. Command injection in airflow DAG (cve-2020-11978)
GFS分布式文件系统
基于YOLOv3的口罩佩戴检测
nacos -分布式事务-Seata** linux安装jdk ,mysql5.7启动nacos配置ideal 调用接口配合 (保姆级细节教程)
Seven Devops practices to improve application performance
Cmake tutorial Step3 (requirements for adding libraries)
解决“双击pdf文件,弹出”请安装evernote程序
论文阅读_医疗NLP模型_ EMBERT
ELK日志分析系统
Leetcode exercise - 206 Reverse linked list
在一台服务器上部署多个EasyCVR出现报错“Press any to exit”,如何解决?
RSE2020/云检测:基于弱监督深度学习的高分辨率遥感图像精确云检测
热通孔的有效放置如何改善PCB设计中的热管理?
Operation before or after Teamcenter message registration
Teamcenter 消息注册前操作或后操作
检查命名空间和类
How awesome is the architecture of "12306"?
SQL Server(2)