当前位置:网站首页>Map中的getOrDefualt方法
Map中的getOrDefualt方法
2022-08-11 03:50:00 【初夏0811】
在map中根据key去取值,若取不到则指定默认值。
public class Map_getOrDefault {
public static void main(String[] args) {
Map<String, Object> map = new HashMap();
map.put("java", 19800);
map.put("python", 17800);
map.put(".net", 14800);
System.out.println("java:" + map.get("java"));
System.out.println("php:" + map.getOrDefault("php", 0));
}
}
运行结果如下:
java:19800
php:0
边栏推荐
- The last update time of the tables queried by the two nodes of the rac standby database is inconsistent
- Getting Started with Raspberry Pi (5) System Backup
- LeetCode刷题第17天之《3 无重复字符的最长子串》
- What problems should we pay attention to when building a programmatic trading system?
- Kubernetes集群搭建Zabbix监控平台
- 【愚公系列】2022年08月 Go教学课程 035-接口和继承和转换与空接口
- 【C语言】入门
- 互换性与测量技术-公差原则与选用方法
- 构建程序化交易系统需要注意什么问题?
- 程序化交易的策略类型可以分为哪几种?
猜你喜欢
2022-08-10 The sixth group Hiding spring study notes
【FPGA】SDRAM
UNI-APP_iphone苹果手机底部安全区域
A simple JVM tuning, learn to write it on your resume
[FPGA] Design Ideas - I2C Protocol
leetcode刷题第13天二叉树系列之《98 BST及其验证》
E-commerce project - mall time-limited seckill function system
LeetCode刷题第11天字符串系列之《 58最后一个单词长度》
EasyCVR接入海康大华设备选择其它集群服务器时,通道ServerID错误该如何解决?
A large horse carries 2 stone of grain, a middle horse carries 1 stone of grain, and two ponies carry one stone of grain. It takes 100 horses to carry 100 stone of grain. How to distribute it?
随机推荐
STC8H开发(十五): GPIO驱动Ci24R1无线模块
Watch to monitor
阿里云发布3大高性能计算解决方案
【愚公系列】2022年08月 Go教学课程 036-类型断言
二叉树相关代码题【较全】C语言
leetcode刷题第13天二叉树系列之《98 BST及其验证》
MYSQLg高级------回表
电力机柜数据监测RTU
高校就业管理系统设计与实现
Power Cabinet Data Monitoring RTU
FTP错误代码列表
EasyCVR接入GB28181设备时,设备接入正常但视频无法播放是什么原因?
Rotary array problem: how to realize the array "overall reverse, internal orderly"?"Three-step conversion method" wonderful array
按摩椅控制板的开发让按摩椅变得简约智能
What has programmatic trading changed?
什么是三方支付?
云平台下ESB产品开发步骤说明
Binary tree related code questions [more complete] C language
typedef defines the structure array type
一次简单的 JVM 调优,学会拿去写到简历里