如何基于索引不是关键得到LinkedHashMap的价值? [英] How get value from LinkedHashMap based on index not on key?

查看:424
本文介绍了如何基于索引不是关键得到LinkedHashMap的价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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);

这篇关于如何基于索引不是关键得到LinkedHashMap的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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