java - 如何交换 map 中的两个键

标签 java dictionary key swap

有没有办法在 Java 中交换映射中的两个键?

例如。对于列表,有 Collections.swap(ArrayList,1,2);

最佳答案

你可以使用这个衬垫:

map.put('a', map.put('b', map.get('a')));

关于java - 如何交换 map 中的两个键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4698143/

相关文章:

java - 在非模拟方法中模拟方法

java - 命令行参数中 * 的问题

java - getClass().getResourceAsStream ("/folder") 返回 null

python - 带有 MultiIndex 的 DataFrame

Python:查找包含列表的两个字典之间的区别

key - 通过 Cloudformation 支持 AWS Pinpoint APNS channel

java - Azure java函数无法扩展以处理繁重的eventhub消息?

C# 从字典列表中获取所有键

c# - 在 Json 中更改属性的键

c# - 使用 ProcessCmdKey 按住箭头键按下事件