There's two parts to this question, now that I understand it, and really the fact that you're working with Multimaps isn't very important. It's valuable to try to break problems into its component parts; when you do the problems often become clearer, even trivial seeming.
How do I print successive pairs from a collection?
We need to define a function which will take a Collection (this will let us work with arbitrary Multimaps), and generate your pairs:
public static <V> List<String> genPairs(Collection<V> col) { List<V> ls = ImmutableList.copyOf(col); List<String> ret = new ArrayList<>(); for (int i = 0; i < ls.size()-1; i++) { for (int j = i+1; j < ls.size(); j++) { ret.add(ls.get(i)+", "+ls.get(j)); } } return ret; }
Demo:
for(String pair : genPairs(ImmutableList.of(1,2,3))) { System.out.println(pair); }
1, 2 1, 3 2, 3
How do I print successive pairs from the values of a Multimap?
This part's easy, you just loop over the value collections and call the above function:
for(Collection<String> col : multimap.asMap().values()) { for(String pair : genPairs(col)) { System.out.println(pair); } System.out.println(); }