Need a Java map/table with multiple keys to one value. Value is commonly altered

前端 未结 5 1317
旧巷少年郎
旧巷少年郎 2021-01-04 10:13

What I need is a collection which allows multiple keys to access a single object.

I need to apply frequent alterations to this object.

It also must be effici

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-04 11:01

    Uhm…

    Map map = new HashMap();
    Object someValue = new Object();
    map.put(new Object(), someValue);
    map.put(new Object(), someValue);
    

    Now the map contains the same value twice, accessible via different keys. If that’s not what you’re looking for you should rework your question. :)

提交回复
热议问题