Laurent Hinoul

“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - John F. Woods

How to group map values by key in Java

A Java-map always contain a key and value (<key, value>). That key must always be unique so you can search your value by key. But what if you want to group values by key? Multimap, guava from Google gives you the solution.

Maven:

Jar:

http://mvnrepository.com/artifact/com.google.guava/guava/14.0

Code:

When we just want the values from a key:

Leave a Reply