该方法是根据Map集合的key获取value,如果key不存在,就使用默认值。
代码演示:
Map<String, Map> testMap = new HashMap<>();
Map<String,String> map = null;
if(testMap.containsKey("name")) {
map = testMap.get("name");
} else {
map = new HashMap<>();
}
Map<String, Map> testMap = new HashMap<>();
Map<String,String> map = testMap.getOrDefault("name",new HashMap<String,String>());
© 版权声明
THE END





![The server selected protocol version TLS10 is not accepted by client preferences [TLS12]-深吸氧](https://xiyang-blog.oss-cn-hangzhou.aliyuncs.com/blog/2022/02/20220224201351.png)





暂无评论内容