我有以下方法:
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));
}
}
Run Code Online (Sandbox Code Playgroud)
这输出:
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]
Run Code Online (Sandbox Code Playgroud)
我怎么才能输出唯一的密钥.我希望它只打印一次语句而不是多次重复它.我有一个表,其中不同的行具有重复键,因此我使用MultiMap获取重复键的所有值.我现在如何仅输出 …
我的桌子:
ID Name Status1 Status2
-------------------------------------
1 foo bar grain
2 bar foo sball
3 foo bar grain
4 far boo sball
Run Code Online (Sandbox Code Playgroud)
我需要它实际上这样出来:
ID Name Status
-------------------------------
1 foo bar
1 foo grain
2 bar foo
2 bar sball
3 foo bar
3 foo bar
4 far boo
4 far sball
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢,你能解释一下原因吗?
我尝试过concat,但这显然是错误的.