Nested Maps or combined keys in java

前端 未结 6 1668
一个人的身影
一个人的身影 2020-12-17 21:58

I need a Map to make a cache in Java for same values that I have two String keys. My question it\'s better to make nested Maps (one for each key) or make some type of custom

6条回答
  •  天命终不由人
    2020-12-17 22:41

    You may want to consider Guava's Table classes. They implement a Map with two keys per value. This may provide a more readable solution than a composite key depending on your requirements.

    Table
    

提交回复
热议问题