我有以下方法:如何使用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]
謝謝!