如何基于索引不是关键得到LinkedHashMap的价值?索引、关键、价值、不是

由网友(揉奶師)分享简介:我LinkedHashMap hMap;我想获得名单,其中,字符串> 按位置不是关键我不希望使用迭代。有没有其他办法以指数值?Is there any other way to get Value based on index ?推荐答案您不能得到地图基于指...

LinkedHashMap<String, List<String>> hMap;

我想获得名单,其中,字符串&GT; 按位置不是关键

我不希望使用迭代。

有没有其他办法以指数值?

Is there any other way to get Value based on index ?

推荐答案

您不能得到地图基于指数的值,地图只是不这样的。一种解决方法是创建从你的价值一个新的列表,并获得基于索引的价值。

You can't get the value of the Map based on index, Maps just don't work that way. A workaround would be to create a new list from your values and get the value based on index.

LinkedHashMap<String, List<String>> hMap;
List<List<String>> l = new ArrayList<List<String>>(hMap.values());
l.get(0);
阅读全文

相关推荐

最新文章