I am saving data into a Hashmap
, with a String
being the key
and a List
being the value. How would I be able to access a specific element in the value List
?
For example :
I want to access the element at index 5 within the values List
.
Thanks in advance:)
You can iterate over keys by calling map.entrySet().
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
List<String> list = entry.getValue();
// get value
list.get(5);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.