MAC MAC - 1 year ago 137
Android Question

How get value from LinkedHashMap based on index not on key?

I have

LinkedHashMap<String, List<String>> hMap;

I want to get
by position not on key.

I don't want to use iterate.

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

Answer Source

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());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download