java多映射arraylist [英] java multi mapping arraylist

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

问题描述

是否可以将键映射到多维数组列表.一些像下面的例子..

Is it possible to map key to Multi Dimensional Array List. Some thing like following example..

Map<K,V>

其中 K 是字母列表的键,V 是存储单词列表的多维数组列表或普通数组列表.类似于读取字典文件的应用程序.我想看一个例子.示例可以是与 Map 和 Multi Dimensional Array-list 相关的任何内容.或者有没有其他有效的方法来实现集合?我从来没有使用过这样的实现,所以如果已经有一个与我的 QA 相关的线程,请发布链接.

Where K is key for list of alphabet and V is a multi dimensional array list or normal array list that stores list of word. Some thing like a application that reads a dictionary file. I want to see an example. Example can be anything related to Map and Multi Dimensional Array-list. Or is there any other efficient way to implement collection? I have never used such implementations so if there is already a thread related to mine QA please post the link.

推荐答案

您可以使用 Guava's Multimap's 如果您想将多个值与单个键相关联.你需要 ArrayListMultimap针对您的具体情况.

You can use Guava's Multimap's if you want to associate multiple values with a single key. You need ArrayListMultimap for your specific case.

示例

ListMultimap<String, String> dict= new ArrayListMultimap<String, String>();
dict.put("key 1", "value 1");
dict.put("key 1", "value 2");
dict.put("key 2", "value 1");

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

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