字典类 [英] Dictionary class

查看:105
本文介绍了字典类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在Java字典类中为单个键设置多个值。

Is it possible to have multiple values, for a single key, in the Java dictionary class?

推荐答案

字典类:该类被认为是obselete,文档建议使用Map代替。

First, regarding the dictionary class: That class is considered obselete, the documentation recommends using Map instead.

您正在寻找的这种集合称为多图。
你可以用一个列表实现一个,但是很繁琐。

This kind of collection you are seeking is called a multimap. You could implement one yourself with a list, but that is tedious.

你可以使用来自Apache Collections或者Google Collections的MultiMap。虽然我个人是apache集合的粉丝,他们不真正支持泛型,所以一个Google multimap可能会更安全。

You may want to use a MultiMap from either Apache Collections or from the Google Collections. While I am personally a fan of the apache collections, they do not really support generics, so a Google multimap may be safer.

这篇关于字典类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆