我有以下方法:如何使用Guava的MultiMap输出唯一的密钥? (JAVA)
public static void showStuff(Multimap<String, String> map) {
for (String key : map.keys()) {
System.out.println("The key, " + key
+ ", has the results: " + map.get(key));
}
}
此输出:
The key, **one**, has the results: [a,b,c,d,d,e]
The key, **one**, has the results: [a,b,c,d,d,e]
The key, **one**, has the results: [a,b,c,d,d,e]
The key, **one**, has the results: [a,b,c,d,d,e]
The key, **one**, has the results: [a,b,c,d,d,e]
The key, **two**, has the results: [a,a,a,b,b,e]
The key, **two**, has the results: [a,a,a,b,b,e]
我怎么会有它只能输出唯一的密钥。我希望它只打印一次陈述,而不是多次重复陈述。我有一个包含重复键的不同行的表,因此我使用MultiMap获取重复键的所有值。我现在将如何输出
The key, **one**, has the results: [a,b,c,d,d,e]
The key, **two**, has the results: [a,a,a,b,b,e]
谢谢!