I have a Multimap where each key gets a variable number of values assigned to it. In case there are multiple values in 1 key, I want to do operations with the values. It was easy to find online how to iterate over the keys in a Multimap, but can't seem to find how to iterate over all values for a specific key. Can u help?
Asked
Active
Viewed 259 times
-2
-
3What does the documentation of the multimap implementation you picked suggest? – kryger Feb 02 '18 at 15:36
-
Hi Kryger, I don't know, I guess I don't know what to look for because of a lack of Java skills. I can access "a view collection of the data" by using the key and get(), but how to iterate over this view collection? Sorry if my question seems dumb :) – blah_crusader Feb 02 '18 at 15:46
-
As a general principle you'll need to share the relevant bit of your code that demonstrates the problem, ideally self-contained and runnable. In this case, the important bit will be the imports - Java standard SDK doesn't offer a multimap implementation, you're *probably* using Guava but *this is* what you need to share before asking for help – kryger Feb 02 '18 at 20:00
1 Answers
0
Per the commentary, your method get returns a collection, in this case
map.get(key).forEach(entry -> {
//do what you need
});
To be able to provide more details, documentation is needed. Or at least a pointer to the library you are using.

Victor
- 3,520
- 3
- 38
- 58