HashMap with multiple values under the same key

前端 未结 22 2180
旧时难觅i
旧时难觅i 2020-11-22 06:49

Is it possible for us to implement a HashMap with one key and two values. Just as HashMap?

Please do help me, also by telling (if there is no way) any other way to

22条回答
  •  忘掉有多难
    2020-11-22 06:58

    If you use Spring Framework. There is: org.springframework.util.MultiValueMap.

    To create unmodifiable multi value map:

    Map> map = ...
    MultiValueMap multiValueMap = CollectionUtils.toMultiValueMap(map);
    

    Or use org.springframework.util.LinkedMultiValueMap

提交回复
热议问题