You can just use this:
List<String> words = Arrays.asList("a b c d e a b c".split("\\s+"));
Multimap<String, Integer> tokenMap = IntStream.range(0, words.size()).boxed()
.collect(ArrayListMultimap::create, (m, i) -> m.put(words.get(i), i), Multimap::putAll);
The result will be:
{a=[0, 5], b=[1, 6], c=[2, 7], d=[3], e=[4]}
善于将复杂问题简单化