小编Yas*_*eni的帖子

如何使用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));
        }
    }
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获取重复键的所有值.我现在如何仅输出 …

java key hashmap multimap guava

2
推荐指数
1
解决办法
1138
查看次数

将两个独立列的结果合并为一个细长列

我的桌子:

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,但这显然是错误的.

sql oracle select

0
推荐指数
1
解决办法
46
查看次数

标签 统计

guava ×1

hashmap ×1

java ×1

key ×1

multimap ×1

oracle ×1

select ×1

sql ×1