Collections.singletonMap
时间: 2023-10-19 14:35:23 浏览: 86
Collections.singletonMap()是Java中的一个方法,用于创建一个只包含一个键值对的不可变Map(即Map接口的实现类)。它接受两个参数,分别是键和值,并返回一个Map实例,大小为1,包含指定的键和值。该方法定义在java.util包中的Collections类中。使用该方法创建的Map实例不能被修改,如果尝试修改该实例,会抛出java.lang.UnsupportedOperationException异常。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Collections.singletonMap()用法](https://blog.csdn.net/ZGL_cyy/article/details/114919899)[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: 50%"]
- *2* *3* [Java中的Collections.singletonMap()方法及其示例](https://blog.csdn.net/tck001221/article/details/132269217)[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: 50%"]
[ .reference_list ]
阅读全文