hashmap存空值
时间: 2023-10-19 07:31:52 浏览: 120
HashMap可以存储空值。根据引用的内容,HashMap的key和value都可以为null。也就是说,你可以将null作为HashMap的key或者value存储进去。但需要注意的是,为null的key只能有一个,而为null的value可以有多个。如果你给多个key都赋值null,最终也只会有一个key存储进来。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [java程序员面试题](https://download.csdn.net/download/liyongshuang217/1344675)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [HashMap系列:HashMap的key、value空值问题](https://blog.csdn.net/zhangjin1120/article/details/114916529)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [高薪程序员&面试题精讲系列34之List、Set、Map可不可以存空值?](https://blog.csdn.net/syc000666/article/details/121805566)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文